Unverified Commit ec07bf12 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Add `<link>` attributes in proper order (#16319)

1. `as` should be set before `rel` in case of `preload` or `prefetch`
2. `href` should be after `onload` and `onerror`
parent 5f975500
...@@ -61,13 +61,15 @@ export function createLink( ...@@ -61,13 +61,15 @@ export function createLink(
return [ return [
link, link,
new Promise((res, rej) => { new Promise((res, rej) => {
link!.crossOrigin = process.env.__NEXT_CROSS_ORIGIN! // The order of property assignment here is intentional:
link!.href = href
link!.rel = rel
if (as) link!.as = as if (as) link!.as = as
link!.rel = rel
link!.crossOrigin = process.env.__NEXT_CROSS_ORIGIN!
link!.onload = res link!.onload = res
link!.onerror = rej link!.onerror = rej
// `href` should always be last:
link!.href = href
}), }),
] ]
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment