Skip to content

Commit d2e15fc

Browse files
committed
[mediaqueries-5] Add example
This helps lift the confusion that prompted #5458
1 parent 968bf7e commit d2e15fc

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

mediaqueries-5/Overview.bs

+26
Original file line numberDiff line numberDiff line change
@@ -2606,6 +2606,32 @@ Custom Media Queries</h2>
26062606
If <dfn value for="@custom-media">true</dfn> or <dfn value for="@custom-media">false</dfn> is given,
26072607
the <a>custom media query</a> evaluates to true or false, respectively.
26082608

2609+
<div class=example>
2610+
The [=custom media query=] is evaluated logically, not treated as a textual substitution.
2611+
Take the following code snippet for instance:
2612+
<pre><code class=lang-css>
2613+
/* --modern targets modern devices that support color or hover */
2614+
@custom-media --modern (color), (hover);
2615+
2616+
@media (--modern) and (width > 1024px) {
2617+
.a { color: green; }
2618+
}
2619+
</code></pre>
2620+
It is equivalent to:
2621+
<pre><code class=lang-css>
2622+
@media ((color) or (hover)) and (width > 1024px) {
2623+
.a { color: green; }
2624+
}
2625+
</code></pre>
2626+
2627+
Processing it as if it meant the following would be incorrect:
2628+
<pre><code class=lang-css>
2629+
@media (color), (hover) and (width > 1024px) {
2630+
.a { color: green; }
2631+
}
2632+
</code></pre>
2633+
</div>
2634+
26092635
A ''@custom-media'' rule can refer to other <a>custom media queries</a>.
26102636
However, loops are forbidden,
26112637
and a <a>custom media query</a> must not be defined in terms of itself or

0 commit comments

Comments
 (0)