Skip to content

Commit 1b6f84a

Browse files
committed
Fix bugs in source parser
Fixes #9648, fixes #9649
1 parent e90b823 commit 1b6f84a

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

source

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29769,9 +29769,8 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</code
2976929769
<p>This example is the same as the previous example, but the image is <span
2977029770
data-x="attr-loading-lazy-state">lazy-loaded</span>. In this case, the <code
2977129771
data-x="attr-img-sizes">sizes</code> attribute can use the <code
29772-
data-x="valdef-sizes-auto">auto</code> keyword (or the <code
29773-
data-x="attr-img-sizes">sizes</code> attribute can be omitted), and the user agent will use the
29774-
<code data-x="attr-dim-width">width</code> attribute (or the width specified in CSS) for the
29772+
data-x="valdef-sizes-auto">auto</code> keyword, and the user agent will use the <code
29773+
data-x="attr-dim-width">width</code> attribute (or the width specified in CSS) for the
2977529774
<span>source size</span>.</p>
2977629775

2977729776
<pre><code class="html">&lt;img <strong>loading="lazy" width="200" height="200" sizes="auto"</strong>
@@ -30068,7 +30067,8 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</code
3006830067
<span>update the image data</span> or <span data-x="img-environment-changes">react to environment
3006930068
changes</span> algorithms) <span>allows auto-sizes</span> and is <span>being rendered</span>,
3007030069
then <code data-x="valdef-sizes-auto">auto</code> is the <span>concrete object size</span> width.
30071-
Otherwise, <code data-x="valdef-sizes-auto">auto</code> is <code data-x="">100vw</code>.</p>
30070+
Otherwise, the <code data-x="valdef-sizes-auto">auto</code> value is ignored and the next
30071+
<span>source size</span> is used instead, if any.</p>
3007230072

3007330073
<p>The <code data-x="valdef-sizes-auto">auto</code> keyword may be specified in the <code
3007430074
data-x="attr-source-sizes">sizes</code> attribute of <code>source</code> elements and <code
@@ -31406,13 +31406,28 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</code
3140631406
Otherwise, there is a <span data-x="concept-microsyntax-parse-error">parse error</span>;
3140731407
<span>continue</span>.</p></li>
3140831408

31409-
<li><p>Remove all consecutive <span>&lt;whitespace-token></span>s
31410-
from the end of <var>unparsed size</var>.
31411-
If <var>unparsed size</var> is now empty,
31412-
then return <var>size</var>.
31413-
If this was not the keyword <code data-x="valdef-sizes-auto">auto</code> and
31414-
it was not the last item in <var>unparsed sizes list</var>,
31415-
that is a <span data-x="concept-microsyntax-parse-error">parse error</span>.</p></li>
31409+
<li>
31410+
<p>If <var>size</var> is <code data-x="valdef-sizes-auto">auto</code>, and <var>img</var>
31411+
is not null, and <var>img</var> is <span>being rendered</span>, and <var>img</var>
31412+
<span>allows auto-sizes</span>, then set <var>size</var> to the <span>concrete object
31413+
size</span> width of <var>img</var>, in <span data-x="'px'">CSS pixels</span>.</p>
31414+
31415+
<p class="note">If <var>size</var> is still <code data-x="valdef-sizes-auto">auto</code>,
31416+
then it will be ignored.</p>
31417+
</li>
31418+
31419+
<li>
31420+
<p>Remove all consecutive <span>&lt;whitespace-token></span>s from the end of <var>unparsed
31421+
size</var>. If <var>unparsed size</var> is now empty:</p>
31422+
31423+
<ol>
31424+
<li><p>If this was not the last item in <var>unparsed sizes list</var>, that is a <span
31425+
data-x="concept-microsyntax-parse-error">parse error</span>.</p></li>
31426+
31427+
<li><p>If <var>size</var> is not <code data-x="valdef-sizes-auto">auto</code>, then return
31428+
<var>size</var>. Otherwise, continue.</p></li>
31429+
</ol>
31430+
</li>
3141631431

3141731432
<li><p>Parse the remaining <span data-x="component value">component values</span> in <var>unparsed size</var>
3141831433
as a <span>&lt;media-condition></span>.
@@ -31421,18 +31436,11 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</code
3142131436
<span>continue</span>. <ref>MQ</ref></p></li>
3142231437

3142331438
<li><p>If <var>size</var> is not <code data-x="valdef-sizes-auto">auto</code>, then return
31424-
<var>size</var>.</p></li>
31439+
<var>size</var>. Otherwise, continue.</p></li>
3142531440
</ol>
3142631441
</li>
3142731442

31428-
<li><p>Assert: <var>size</var> is null or <code data-x="valdef-sizes-auto">auto</code>.</p></li>
31429-
31430-
<li><p>If <var>img</var> is null, or <var>img</var> is not <span>being rendered</span>, or
31431-
<var>img</var> does not <span data-x="allows auto-sizes">allow auto-sizes</span>, then return
31432-
<code data-x="">100vw</code>.</p></li>
31433-
31434-
<li><p>Return the <span>concrete object size</span> width of <var>img</var>, in <span
31435-
data-x="'px'">CSS pixels</span>.</p></li>
31443+
<li><p>Return <code data-x="">100vw</code>.</p></li>
3143631444
</ol>
3143731445

3143831446
<p class="note">It is invalid to use a bare <span>&lt;source-size-value></span> that is a <span>&lt;length></span>

0 commit comments

Comments
 (0)