8000 [cssom][css-nesting] Per #8940, CSSStyleRule inherits from CSSGroupin… · w3c/csswg-drafts@4810428 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4810428

Browse files
committed
[cssom][css-nesting] Per #8940, CSSStyleRule inherits from CSSGroupingRule, so remove the now extraneous definitions from Nesting.
1 parent
8000
 e695902 commit 4810428

File tree

2 files changed

+45
-42
lines changed

2 files changed

+45
-42
lines changed

css-nesting-1/Overview.bs

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ spec:css-values-4; type:dfn; text:identifier
1818
spec: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}
10641068
CSSOM {#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+ 8000
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.

cssom-1/Overview.bs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ The <code>CSSStyleRule</code> interface represents a style rule.
19981998

19991999
<pre class=idl>
20002000
[Exposed=Window]
2001-
interface CSSStyleRule : CSSRule {
2001+
interface CSSStyleRule : CSSGroupingRule {
20022002
attribute CSSOMString selectorText;
20032003
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
20042004
};

0 commit comments

Comments
 (0)
0