Skip to content

Commit

Permalink
Editorial: Deduplicate link request creation
Browse files Browse the repository at this point in the history
  • Loading branch information
noamr committed Jun 3, 2022
1 parent 94a9b1d commit 5a9cd4b
Showing 1 changed file with 43 additions and 66 deletions.
109 changes: 43 additions & 66 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -14274,8 +14274,11 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
<var>el</var>, is as follows:</p>

<ol>
<li><p>Let <var>request</var> be the result of <span data-x="create a link element
request">creating a <code>link</code> element request</span> given <var>el</var>.</p></li>
<li><p>Let <var>options</var> be the result of <span data-x="create link options from
element">creating link options</span> from <var>el</var>.</p></li>

<li><p>Let <var>request</var> be the result of <span data-x="create a link request">creating a
link request</span> given <var>options</var>.</p></li>

<li><p>If <var>request</var> is null, then return.</p></li>

Expand All @@ -14284,10 +14287,9 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
<li><p>Run the <span>linked resource fetch setup steps</span>, given <var>el</var> and
<var>request</var>. If the result is false, then return.</p></li>

<li><p>Let <var>initiatorType</var> be "<code data-x="">css</code>" if <var>el</var>'s
<code data-x="attr-link-rel">rel</code> attribute contains the keyword
<code data-x="rel-stylesheet">stylesheet</code>; "<code data-x="">link</code>"
otherwise.</p></li>
<li><p>Let <var>initiatorType</var> be "<code data-x="">css</code>" if <var>el</var>'s <code
data-x="attr-link-rel">rel</code> attribute contains the keyword <code
data-x="rel-stylesheet">stylesheet</code>; "<code data-x="">link</code>" otherwise.</p></li>

<li>
<p><!--FETCH--><span data-x="concept-fetch">Fetch</span> <var>request</var> with <i
Expand Down Expand Up @@ -14325,39 +14327,44 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
</li>
</ol>

<p>To <dfn data-x="create a link element request">create a <code>link</code> element request</dfn>
given a <code>link</code> element <var>el</var> and an optional string <var>destination</var>
(default the empty string):</p>
<p>To <dfn>create a link request</dfn> given a <span>link processing options</span>
<var>options</var>:</p>

<ol>
<li><p>If <var>el</var>'s <code data-x="attr-link-href">href</code> attribute's value is the
empty string, then return null.</p></li>
<li><p>Assert: <var>options</var>'s <span data-x="link options href">href</span> is not the
empty string.</p></li>

<li><p><span>Parse a URL</span> given <var>el</var>'s <code data-x="attr-link-href">href</code>
attribute, relative to <var>el</var>'s <span>node document</span>. If that fails, then return
null. Otherwise, let <var>url</var> be the <span>resulting URL record</span>.</p></li>
<li><p>If <var>options</var>'s <span data-x="link options destination">destination</span> is not
a <span data-x="concept-request-destination">destination</span>, then return null.</p></li>

<li><p>Let <var>corsAttributeState</var> be the current state of <var>el</var>'s <code
data-x="attr-link-crossorigin">crossorigin</code> content attribute.</p></li>
<li><p><span>Parse a URL</span> given <var>options</var>'s <span data-x="link options
href">href</span>, relative to <var>options</var>'s <span data-x="link options base url">base
URL</span>. If that fails, then return null. Otherwise, let <var>url</var> be the
<span>resulting URL record</span>.</p></li>

<li><p>Let <var>request</var> be the result of <span data-x="create a potential-CORS
request">creating a potential-CORS request</span> given <var>url</var>, <var>destination</var>,
and <var>corsAttributeState</var>.</p></li>

<li><p>Set <var>request</var>'s <span data-x="concept-request-client">client</span> to
<var>el</var>'s <span>node document</span>'s <span>relevant settings object</span>.</p></li>
request">creating a potential-CORS request</span> given <var>url</var>, <var>options</var>'s
<span data-x="link options destination">destination</span>, and <var>options</var>'s <span
data-x="link options crossorigin">crossorigin</span>.</p></li>

<li><p>Set <var>request</var>'s <span data-x="concept-request-nonce-metadata">cryptographic
nonce metadata</span> to the current value of <var>el</var>'s
<span>[[CryptographicNonce]]</span> internal slot.</p></li>
<li><p>Set <var>request</var>'s <span data-x="concept-request-policy-container">policy
container</span> to <var>options</var>'s <span data-x="link options policy container">policy
container</span>.</p></li>

<li><p>Set <var>request</var>'s <span data-x="concept-request-integrity-metadata">integrity
metadata</span> to the current value of <var>el</var>'s <code
data-x="attr-link-integrity">integrity</code> content attribute.</p></li>
metadata</span> to <var>options</var>'s <span data-x="link options
integrity">integrity</span>.</p></li>

<li><p>Set <var>request</var>'s <span data-x="concept-request-nonce-metadata">cryptographic
nonce metadata</span> to <var>options</var>'s <span data-x="link options nonce">cryptographic
nonce metadata</span>.</p></li>

<li><p>Set <var>request</var>'s <span data-x="concept-request-referrer-policy">referrer
policy</span> to the current state of <var>el</var>'s <code
data-x="attr-link-referrerpolicy">referrerpolicy</code> content attribute.</p></li>
policy</span> to <var>options</var>'s <span data-x="link options referrer policy">referrer
policy</span>.</p></li>

<li><p>Set <var>request</var>'s <span data-x="concept-request-client">client</span> to
<var>options</var>'s <span data-x="link options environment">environment</span>.</p></li>

<li><p>Return <var>request</var>.</p></li>
</ol>
Expand Down Expand Up @@ -26517,54 +26524,24 @@ document.body.appendChild(wbr);</code></pre>
data-x="concept-response">response</span>:</p>

<ol>
<li><p>If <var>options</var>'s <span data-x="link options destination">destination</span> is not
a <span data-x="concept-request-destination">destination</span>, then return.</p></li>

<li><p>If <var>options</var>'s <span data-x="link options type">type</span> doesn't <span
data-x="match preload type">match</span> <var>options</var>'s <span
data-x="link options destination">destination</span>, then return.</p></li>

<li><p>Let <var>href</var> be <var>options</var>'s <span
data-x="link options href">href</span>.</p></li>

<li><p>If <var>options</var>'s <span data-x="link options destination">destination</span> is
"<code data-x="">image</code>" and <var>options</var>'s <span
data-x="link options source set">source set</span> is not null, then set <var>href</var>
to the result of <span
data-x="select an image source from a source set">selecting an image source</span> from
<var>options</var>'s <span data-x="link options source set">source set</span>.</p></li>
"<code data-x="">image</code>" and <var>options</var>'s <span data-x="link options source
set">source set</span> is not null, then set <var>options</var>'s <span data-x="link options
href">href</span> to the result of <span data-x="select an image source from a source
set">selecting an image source</span> from <var>options</var>'s <span data-x="link options
source set">source set</span>.</p></li>

<li><p>If <var>href</var> is an empty string, return.</p></li>
<li><p>Let <var>request</var> be the result of <span data-x="create a link request">creating a
link request</span> given <var>options</var>.</p></li>

<li><p><span data-x="parse a url">Parse</span> <var>href</var> relative to
<var>options</var>'s <span data-x="link options base URL">base URL</span>. If that fails, then
return. Otherwise let <var>url</var> be the <span>resulting URL record</span>.</p></li>
<li><p>If <var>request</var> is null, then return.</p></li>

<li><p>Let <var>unsafeEndTime</var> be 0.</p></li>

<li><p>Let <var>response</var> be "<code data-x="">pending</code>".</p></li>

<li><p>Let <var>request</var> be the result of <span data-x="create a potential-CORS
request">creating a potential-CORS request</span> given <var>url</var>, <var>destination</var>,
and <var>options</var>'s <span data-x="link options crossorigin">crossorigin</span>.</p></li>

<li><p>Set <var>request</var>'s <span data-x="concept-request-policy-container">policy
container</span> to <var>options</var>'s <span
data-x="link options policy container">policy container</span>.</p></li>

<li><p>Set <var>request</var>'s <span
data-x="concept-request-integrity-metadata">integrity metadata</span> to <var>options</var>'s
<span data-x="link options integrity">integrity</span>.</p></li>

<li><p>Set <var>request</var>'s <span
data-x="concept-request-nonce-metadata">cryptographic nonce metadata</span> to
<var>options</var>'s <span
data-x="link options nonce">cryptographic nonce metadata</span>.</p></li>

<li><p>Set <var>request</var>'s <span
data-x="concept-request-referrer-policy">referrer policy</span> to <var>options</var>'s
<span data-x="link options referrer policy">referrer policy</span>.</p></li>

<li><p>Let <var>entry</var> be a new <span>preload entry</span> whose
<span data-x="preload integrity metadata">integrity metadata</span> is <var>options</var>'s
<span data-x="link options integrity">integrity</span>.</p></li>
Expand Down

0 comments on commit 5a9cd4b

Please sign in to comment.