Skip to content

Commit c1a685d

Browse files
authored
Merge pull request w3c#3900 from emilio/CSSStyleSheet-sadness
[cssom] Define legacy CSSStyleSheet methods as implemented in Blink.
2 parents 82cb3a4 + 0f10d5e commit c1a685d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

cssom-1/Overview.bs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,39 @@ The <dfn method for=CSSStyleSheet>deleteRule(<var>index</var>)</dfn> method must
949949
<li><a>Remove a CSS rule</a> in the <a for=CSSStyleSheet>CSS rules</a> at <var>index</var>.
950950
</ol>
951951

952+
#### Legacy CSSStyleSheet members #### {#legacy-css-style-sheet-members}
953+
954+
<p class=advisement>
955+
Note: These members are required for compatibility with existing sites.
956+
Authors are encouraged to use the standard members defined above instead,
957+
which are consistent with {{CSSGroupingRule}}.
958+
</p>
959+
960+
<pre class=idl>
961+
partial interface CSSStyleSheet {
962+
[SameObject] readonly attribute CSSRuleList rules;
963+
long addRule(optional DOMString selector = "undefined", optional DOMString style = "undefined", optional unsigned long index);
964+
void removeRule(optional unsigned long index = 0);
965+
};
966+
</pre>
967+
968+
The <dfn attribute for=CSSStyleSheet>rules</dfn> attribute must follow the same steps as {{CSSStyleSheet/cssRules}}, and return the same object {{CSSStyleSheet/cssRules}} would return.
969+
970+
The <dfn method for=CSSStyleSheet>removeRule(<var>index</var>)</dfn> method must run the same steps as {{CSSStyleSheet/deleteRule()}}.
971+
972+
The <dfn method for=CSSStyleSheet>addRule(<var>selector</var>, <var>block</var>, <var>optionalIndex</var>)</dfn> method must run the following steps:
973+
974+
<ol>
975+
<li>Let <var>rule</var> be an empty string.
976+
<li>Append <var>selector</var> to <var>rule</var>.
977+
<li>Append <code>" { "</code> to <var>rule</var>.
978+
<li>If <var>block</var> is not empty, append <var>block</var>, followed by a space, to <var>rule</var>.
979+
<li>Append <code>"}"</code> to <var>rule</var>
980+
<li>Let <var>index</var> be <var>optionalIndex</var> if provided, or the number of <a for=CSSStyleSheet>CSS rules</a> in the stylesheet otherwise.
981+
<li>Call {{CSSStyleSheet/insertRule()}}, with <var>rule</var> and <var>index</var> as arguments.
982+
<li>Return <code>-1</code>.
983+
</ol>
984+
952985
CSS Style Sheet Collections {#css-style-sheet-collections}
953986
----------------------------------------------------------
954987

0 commit comments

Comments
 (0)