Skip to content

Commit ad28192

Browse files
authored
Clarify preload "as" processing
- The link options destination is always a "destination type". - We only use the "preload" translating when preloading. - An invalid "as" translates to an empty string, which would cancel the preload request down the line. - The default remains the empty string, and rel=icon can set the request's destination manually to image as before. Closes #11726.
1 parent a3b502b commit ad28192

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

source

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,6 +2742,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
27422742
<li><dfn data-x="concept-request-traversable-for-user-prompts" data-x-href="https://fetch.spec.whatwg.org/#concept-request-window">traversable for user prompts</dfn></li>
27432743
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#request-top-level-navigation-initiator-origin">top-level navigation initiator origin</dfn></li>
27442744
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#concept-request-add-range-header">add a range header</dfn></li>
2745+
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#destination-type">destination type</dfn></li>
27452746
</ul>
27462747
</li>
27472748
<li>
@@ -16764,7 +16765,6 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
1676416765

1676516766
<dl>
1676616767
<dt><dfn data-x="link options href">href</dfn> (default the empty string)</dt>
16767-
<dt><dfn data-x="link options destination">destination</dfn> (default the empty string)</dt>
1676816768
<dt><dfn data-x="link options initiator">initiator</dfn> (default "<code
1676916769
data-x="">link</code>")</dt>
1677016770
<dt><dfn data-x="link options integrity">integrity</dfn> (default the empty string)</dt>
@@ -16773,6 +16773,9 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
1677316773
string)</dt>
1677416774
<dd>A string</dd>
1677516775

16776+
<dt><dfn data-x="link options destination">destination</dfn> (default the empty string)</dt>
16777+
<dd>A <span>destination type</span>.</dd>
16778+
1677616779
<dt><dfn data-x="link options crossorigin">crossorigin</dfn> (default <span
1677716780
data-x="attr-crossorigin-none">No CORS</span>)</dt>
1677816781
<dd>A <span>CORS settings attribute</span> state</dd>
@@ -16823,11 +16826,6 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
1682316826
<p>Let <var>options</var> be a new <span>link processing options</span> with</p>
1682416827

1682516828
<dl class="props">
16826-
<dt><span data-x="link options destination">destination</span></dt>
16827-
<dd>the result of <span
16828-
data-x="translate a preload destination">translating</span> the state of <var>el</var>'s <code
16829-
data-x="attr-link-as">as</code> attribute</dd>
16830-
1683116829
<dt><span data-x="link options crossorigin">crossorigin</span></dt>
1683216830
<dd>the state of <var>el</var>'s <code data-x="attr-link-crossorigin">crossorigin</code>
1683316831
content attribute</dd>
@@ -16980,7 +16978,7 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
1698016978
</li>
1698116979

1698216980
<li><p><span>Apply link options from parsed header attributes</span> to <var>options</var>
16983-
given <var>attribs</var>.</p></li>
16981+
given <var>attribs</var> and <var>rel</var>. If that returned false, then return.</p></li>
1698416982

1698516983
<li><p>If <var>attribs</var>["<code data-x="attr-link-imagesrcset">imagesrcset</code>"] <span
1698616984
data-x="map exists">exists</span> and <var>attribs</var>["<code
@@ -17000,14 +16998,26 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
1700016998

1700116999
<div algorithm>
1700217000
<p>To <dfn>apply link options from parsed header attributes</dfn> to a <span>link processing
17003-
options</span> <var>options</var> given <var>attribs</var>:</p>
17001+
options</span> <var>options</var> given <var>attribs</var> and a string <var>rel</var>:</p>
1700417002

1700517003
<ol>
17006-
<li><p>If <var>attribs</var>["<code data-x="attr-link-as">as</code>"] <span data-x="map
17007-
exists">exists</span>, then set <var>options</var>'s <span data-x="link options
17008-
destination">destination</span> to the result of <span
17009-
data-x="translate a preload destination">translating</span> <var>attribs</var>["<code
17010-
data-x="attr-link-as">as</code>"].</p></li>
17004+
<li>
17005+
<p>If <var>rel</var> is "<code data-x="rel-preload">preload</code>":</p>
17006+
17007+
<ol>
17008+
<li><p>If <var>attribs</var>["<code data-x="attr-link-as">as</code>"] does not <span
17009+
data-x="map exists">exist</span>, then return false.</p></li>
17010+
17011+
<li><p>Let <var>destination</var> be the result of <span data-x="translate a preload
17012+
destination">translating</span> <var>attribs</var>["<code
17013+
data-x="attr-link-as">as</code>"].</p></li>
17014+
17015+
<li><p>If <var>destination</var> is null, then return false.</p></li>
17016+
17017+
<li><p>Set <var>options</var>'s <span data-x="link options destination">destination</span> to
17018+
<var>destination</var>.</p></li>
17019+
</ol>
17020+
</li>
1701117021

1701217022
<li><p>If <var>attribs</var>["<code data-x="attr-link-crossorigin">crossorigin</code>"] <span
1701317023
data-x="map exists">exists</span> and is an <span>ASCII case-insensitive</span> match for one of
@@ -17039,6 +17049,8 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
1703917049
a <span>fetch priority attribute</span> keyword, then set <var>options</var>'s <span
1704017050
data-x="link options fetch priority">fetch priority</span> to that <span>fetch priority
1704117051
attribute</span> keyword.</p></li>
17052+
17053+
<li><p>Return true.</p></li>
1704217054
</ol>
1704317055
</div>
1704417056

@@ -17190,7 +17202,7 @@ data-x="rel-preload">preload</span>; <span data-x="attr-link-as">as</span>=font<
1719017202
</li>
1719117203

1719217204
<li><p><span>Apply link options from parsed header attributes</span> to <var>options</var>
17193-
given <var>attribs</var>.</p></li>
17205+
given <var>attribs</var> and <var>rel</var>. If that returned false, then return.</p></li>
1719417206

1719517207
<li><p>Run the <span>process a link header</span> steps for <var>rel</var> given
1719617208
<var>options</var>.</p></li>
@@ -28989,7 +29001,7 @@ document.body.appendChild(wbr);</code></pre>
2898929001
<ol>
2899029002
<li><p>If <var>destination</var> is not "<code data-x="">fetch</code>", "<code data-x="">font</code>",
2899129003
"<code data-x="">image</code>", "<code data-x="">script</code>", "<code data-x="">style</code>",
28992-
or "<code data-x="">track</code>", then return null.</p></li>
29004+
or "<code data-x="">track</code>", then return nulll.</p></li>
2899329005

2899429006
<li><p>Return the result of <span
2899529007
data-x="concept-potential-destination-translate">translating</span>
@@ -29112,6 +29124,15 @@ document.body.appendChild(wbr);</code></pre>
2911229124
data-x="create link options from element">creating link options</span> from
2911329125
<var>el</var>.</p></li>
2911429126

29127+
<li><p>Let <var>destination</var> be the result of <span data-x="translate a preload
29128+
destination">translating</span> the keyword representing the state of <var>el</var>'s <code
29129+
data-x="attr-link-as">as</code> attribute.</p></li>
29130+
29131+
<li><p>If <var>destination</var> is null, then return.</p></li>
29132+
29133+
<li><p>Set <var>options</var>'s <span data-x="link options destination">destination</span> to
29134+
<var>destination</var>.</p></li>
29135+
2911529136
<li>
2911629137
<p><span>Preload</span> <var>options</var>, with the following steps given a <span
2911729138
data-x="concept-response">response</span> <var>response</var>:

0 commit comments

Comments
 (0)