@@ -573,8 +573,8 @@ Mixing Nesting Rules and Declarations {#mixing}
573573
574574 <pre class="lang-css">
575575 article {
576- & .blue { color: blue; }
577- & .red { color: red; }
576+ & .blue { color: blue; } /* (0,1,1) */
577+ & .red { color: red; } /* (0,1,1) */
578578 }
579579
580580 /* equivalent to
@@ -588,22 +588,50 @@ Mixing Nesting Rules and Declarations {#mixing}
588588 <div class="red blue"></div>
589589 </article>
590590
591- /* div text color is red */
591+ <!-- div text color is red -->
592592 </pre>
593593
594- and this follow up:
594+ The specificity of ''article .blue'' and ''article .red'' is (0,1,1).
595+
596+ Now consider this follow up which adds an ID selector:
597+
598+ <pre class="lang-css">
599+ article {
600+ & .blue, & #gotcha { color: blue; } /* (1,1,1) */
601+ & .red { color: red; } /* (0,1,1) */
602+ }
603+
604+ /* equivalent to
605+ article :is(.blue, #gotcha) { color: blue; }
606+ article .red { color: red; }
607+ */
608+ </pre>
609+
610+ <pre class="lang-html">
611+ <article>
612+ <div class="red blue"></div>
613+ </article>
614+
615+ <!-- div text color is blue -->
616+ </pre>
617+
618+ ''article :is(.blue, #gotcha)'' now has a specificity score of (1,1,1).
619+ Nesting uses '':is()'' which assumes the specificity of it's highest selector.
620+
621+
622+ To work around it, the following could be written instead:
595623
596624 <pre class="lang-css">
597625 article {
598- & .blue, & #gotcha { color: blue; }
599- & .red { color: red; }
626+ & .blue { color: blue; } /* (0,1,1) */
627+ & .red { color: red; } /* (0,1,1) */
628+ & #gotcha { color: blue; } /* (1,0,1) */
600629 }
601630
602631 /* equivalent to
603- article :is(.blue, #gotcha) {
604- color: blue;
605- }
632+ article .blue { color: blue; }
606633 article .red { color: red; }
634+ article #gotcha { color: blue; }
607635 */
608636 </pre>
609637
@@ -612,14 +640,9 @@ Mixing Nesting Rules and Declarations {#mixing}
612640 <div class="red blue"></div>
613641 </article>
614642
615- /* div text color is blue */
643+ <!-- div text color is red -->
616644 </pre>
617645
618- specificities between ''.red'' and ''.blue''
619- no longer match because the equivalent internal representation of the nesting
620- uses '':is()'' , which becomes the specificity of it's highest selector.
621- The convenience of nesting ''#gotcha'' and ''.blue'' together has joined
622- their specificity, affecting the resolve style, making the color blue.
623646 </div>
624647
625648
0 commit comments