@@ -18,6 +18,10 @@ spec:css-values-4; type:dfn; text:identifier
18
18
spec:cssom-1; type:dfn;
19
19
text:child css rules
20
20
text:specified order
21
+ spec:selectors-4; type:dfn;
22
+ text: combinators
23
+ text: simple selector
24
+ text: type selector
21
25
</pre>
22
26
23
27
<h2 id="intro">
@@ -663,7 +667,7 @@ Nesting Other At-Rules {#conditionals}
663
667
and placed before all other child rules.
664
668
This includes in the OM.
665
669
(That is,
666
- the {{CSSContainerRule/childRules }} attribute
670
+ the {{CSSGroupingRule/cssRules }} attribute
667
671
actually starts with this [=nested style rule=] ,
668
672
containing all the directly-nested properties.)
669
673
@@ -759,7 +763,7 @@ Mixing Nesting Rules and Declarations {#mixing}
759
763
-----------------------------------------------
760
764
761
765
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=] ,
763
767
all three can be arbitrarily mixed.
764
768
However, the relative order of declarations
765
769
vs other rules
@@ -786,7 +790,7 @@ Mixing Nesting Rules and Declarations {#mixing}
786
790
</div>
787
791
788
792
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=]
790
794
are considered to come <em> after</em> their parent rule.
791
795
792
796
<div>
@@ -1064,48 +1068,47 @@ Nesting Selector: the ''&'' selector {#nest-selector}
1064
1068
CSSOM {#cssom}
1065
1069
==============
1066
1070
1067
- Modifications to {{CSSStyleRule}} {#cssom-style}
1068
- ---------------------------------------------
1071
+ Note: [[CSSOM-1]] now defines
1072
+ that {{CSSStyleRule}} can have child rules.
1069
1073
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.
1087
1077
1078
+
8000
When serializing a [=nested group rule=] ,
1079
+ it must serialize solely with child rules.
1088
1080
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'' .
1091
1084
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:
1095
1086
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>
1102
1095
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:
1109
1097
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