Skip to content

Commit f7f26ed

Browse files
committed
[mediaqueries] Add an example of error-recovery with unmatched parens.
1 parent a787342 commit f7f26ed

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

mediaqueries/Overview.bs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,20 @@ Error Handling</h3>
734734

735735
Both of the above <a>media query lists</a> are turned into ''not all, speech'' during parsing,
736736
which has the same truth value as just ''speech''.
737+
738+
Note that error-recovery only happens at the top-level of a <a>media query</a>;
739+
anything inside of an invalid parenthesized block
740+
will just get turned into ''not all'' as a group.
741+
For example:
742+
743+
<pre>
744+
@media (example, speech { /* rules for speech devices */ }
745+
</pre>
746+
747+
Because the parenthesized block is unclosed,
748+
it will contain the entire rest of the stylesheet from that point
749+
(unless it happens to encounter an unmatched ")" character somewhere in the stylesheet),
750+
and turn the entire thing into a ''not all'' <a>media query</a>.
737751
</div>
738752

739753
An unknown <<media-type>> must be treated as not matching.

mediaqueries/Overview.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,19 @@ <h3 class="heading settled heading" data-level=3.1 id=error-handling><span class
12231223

12241224
<p>Both of the above <a data-link-type=dfn href=#media-query-list title="media query lists">media query lists</a> are turned into <span class=css data-link-type=maybe title="not all, speech">not all, speech</span> during parsing,
12251225
which has the same truth value as just <a class=css data-link-type=maybe href=#valuedef-speech title=speech>speech</a>.</p>
1226+
1227+
<p>Note that error-recovery only happens at the top-level of a <a data-link-type=dfn href=#media-query title="media query">media query</a>;
1228+
anything inside of an invalid parenthesized block
1229+
will just get turned into <span class=css data-link-type=maybe title="not all">not all</span> as a group.
1230+
For example:</p>
1231+
1232+
<pre>@media (example, speech { /* rules for speech devices */ }
1233+
</pre>
1234+
1235+
<p>Because the parenthesized block is unclosed,
1236+
it will contain the entire rest of the stylesheet from that point
1237+
(unless it happens to encounter an unmatched ")" character somewhere in the stylesheet),
1238+
and turn the entire thing into a <span class=css data-link-type=maybe title="not all">not all</span> <a data-link-type=dfn href=#media-query title="media query">media query</a>.</p>
12261239
</div>
12271240

12281241
<p>An unknown <a class="production css-code" data-link-type=type href=#typedef-media-type title="<media-type>">&lt;media-type&gt;</a> must be treated as not matching.</p>

0 commit comments

Comments
 (0)