@@ -18,6 +18,10 @@ spec:css-values-4; type:dfn; text:identifier
1818spec:cssom-1; type:dfn;
1919 text:child css rules
2020 text:specified order
21+ spec:selectors-4; type:dfn;
22+ text: combinators
23+ text: simple selector
24+ text: type selector
2125</pre>
2226
2327<h2 id="intro">
@@ -663,7 +667,7 @@ Nesting Other At-Rules {#conditionals}
663667 and placed before all other child rules.
664668 This includes in the OM.
665669 (That is,
666- the {{CSSContainerRule/childRules }} attribute
670+ the {{CSSGroupingRule/cssRules }} attribute
667671 actually starts with this [=nested style rule=] ,
668672 containing all the directly-nested properties.)
669673
@@ -759,7 +763,7 @@ Mixing Nesting Rules and Declarations {#mixing}
759763-----------------------------------------------
760764
761765 When a style rule contains both declarations
762- and [=nested style rules=] or [=nested conditional group rules=] ,
766+ and [=nested style rules=] or [=nested group rules=] ,
763767 all three can be arbitrarily mixed.
764768 However, the relative order of declarations
765769 vs other rules
@@ -786,7 +790,7 @@ Mixing Nesting Rules and Declarations {#mixing}
786790 </div>
787791
788792 For the purpose of determining the [[css-cascade-4#cascade-sort|Order Of Appearance]] ,
789- [=nested style rules=] and [=nested conditional group rules=]
793+ [=nested style rules=] and [=nested group rules=]
790794 are considered to come <em> after</em> their parent rule.
791795
792796 <div>
@@ -1064,48 +1068,47 @@ Nesting Selector: the ''&'' selector {#nest-selector}
10641068CSSOM {#cssom}
10651069==============
10661070
1067- Modifications to {{CSSStyleRule}} {#cssom-style}
1068- ---------------------------------------------
1071+ Note: [[CSSOM-1]] now defines
1072+ that {{CSSStyleRule}} can have child rules.
10691073
1070- CSS style rules gain the ability to have nested rules:
1071-
1072- <pre class=idl>
1073- partial interface CSSStyleRule {
1074- [SameObject] readonly attribute CSSRuleList cssRules;
1075- unsigned long insertRule(CSSOMString rule, optional unsigned long index = 0);
1076- undefined deleteRule(unsigned long index);
1077- };
1078- </pre>
1079-
1080- The <dfn attribute for=CSSStyleRule>cssRules</dfn> attribute
1081- must return a {{CSSRuleList}} object for the [=CSSRule/child CSS rules=] .
1082-
1083- The <dfn method for=CSSStyleRule>insertRule(<var>rule</var>, <var>index</var>)</dfn> method
1084- must return the result of
1085- invoking [=insert a CSS rule=] <var> rule</var>
1086- into the [=CSSRule/child CSS rules=] at <var> index</var> .
1074+ When serializing a [=relative selector=] in a [=nested style rule=] ,
1075+ the selector must be absolutized,
1076+ with the implied [=nesting selector=] inserted.
10871077
1078+ When serializing a [=nested group rule=] ,
1079+ it must serialize solely with child rules.
10881080
1089- The <dfn method for=CSSStyleRule>deleteRule(<var>index</var>)</dfn> method
1090- must [=remove a CSS rule=] from the [=CSSRule/child CSS rules=] at <var> index</var> .
1081+ <div class=example>
1082+ For example, the selector ''> .foo''
1083+ will serialize as ''& > .foo'' .
10911084
1092- Note: Serialization of {{CSSStyleRule}} with nested rules
1093- are already well-defined by [[CSSOM]] ,
1094- via [=serialize a CSS rule=] .
1085+ A [=nested group rule=] like:
10951086
1096- Note: The restriction on what a [=nested style rule's=]
1097- selector can start with
1098- counts as a "constraint imposed by CSS"
1099- in step 5 of [=insert a CSS rule=]
1100- (when invoked by anything that takes [=nested style rules=] ,
1101- not just {{CSSStyleRule}} itself).
1087+ <pre class=lang-css>
1088+ .foo {
1089+ @media (prefers-color-scheme: dark) {
1090+ color: white;
1091+ background: black;
1092+ }
1093+ }
1094+ </pre>
11021095
1103- When setting {{CSSStyleRule/selectorText}} ,
1104- if the {{CSSStyleRule}} is a [=nested style rule=] ,
1105- and the returned group of selectors
1106- starts with a selector
1107- that starts with an ident or function token,
1108- do nothing and return.
1096+ will serialize as:
11091097
1110- Issue: The above paragraph will be inlined into the CSSOM algo,
1111- rather than monkey-patched.
1098+ <pre class=lang-css>
1099+ .foo {
1100+ @media (prefers-color-scheme: dark) {
1101+ & {
1102+ color: white;
1103+ background: black;
1104+ }
1105+ }
1106+ }
1107+ </pre>
1108+ </div>
1109+
1110+ Note: These rules ensure that the rules in question
1111+ are valid to be moved to other contexts,
1112+ including non-nested ones.
1113+ It also ensures that the serialization
1114+ closely matches the structure of the CSSOM.
0 commit comments