Skip to content

Commit 414f264

Browse files
author
Simon Pieters
committed
[cssom] Editorial fixes around insertRule/deleteRule
1 parent d0b9cc1 commit 414f264

2 files changed

Lines changed: 72 additions & 84 deletions

File tree

cssom/Overview.html

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -990,42 +990,11 @@ <h4 id="the-cssstylesheet-interface"><span class="secno">6.1.2 </span>The <code
990990
client-authored script), it can nevertheless change over time due to its liveness status. For example, invoking
991991
the <code title="dom-CSSStyleSheet-insertRule"><a href="#dom-cssstylesheet-insertrule">insertRule()</a></code> or <code title="dom-CSSStyleSheet-deleteRule"><a href="#dom-cssstylesheet-deleterule">deleteRule()</a></code> methods can result in mutations reflected in the returned object.</p>
992992

993-
<p>The <dfn id="dom-cssstylesheet-insertrule" title="dom-CSSStyleSheet-insertRule"><code>insertRule(<var>rule</var>, <var>index</var>)</code></dfn> method performs <dfn id="insert-a-css-rule">insert a CSS rule</dfn> <var>rule</var> as follows:</p>
994-
<ol>
995-
<li><p>Set <var>newRule</var> to the results of performing <a href="#parse-a-css-rule">parse a CSS rule</a>
996-
on argument <var>rule</var>, <a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throwing</a>
997-
a <code class="external"><a href="http://dom.spec.whatwg.org/#syntaxerror">SyntaxError</a></code> exception if a parse error occurs.</li>
998-
<li><p>If <var title="">newRule</var> is an <code title="">@charset</code> at-rule, <a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> a
999-
<code class="external"><a href="http://dom.spec.whatwg.org/#syntaxerror">SyntaxError</a></code> exception.
1000-
<li><p>Set <var>N</var> to <code>cssLength.length</code>.</li>
1001-
<li><p>If argument <var>index</var> is greater than <var>N</var>, then <a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a>
1002-
an <code class="external"><a href="http://dom.spec.whatwg.org/#indexsizeerror">IndexSizeError</a></code> exception.</li>
1003-
<li><p>If the rule <var>newRule</var> cannot be inserted into the specified <var>index</var> due to constraints specified
1004-
by <a href="#refsCSS">[CSS]</a>, then <a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a>
1005-
a <code class="external"><a href="http://dom.spec.whatwg.org/#hierarchyrequesterror">HierarchyRequestError</a></code> exception.</p>
1006-
<p class="note">For example, a CSS style sheet cannot contain an <code title="">@import</code> at-rule after a rule set.</li>
1007-
<li><p>Set <var>newRule</var><code>.parentStyleSheet</code> to <code>this</code> (i.e., this <code><a href="#cssstylesheet">CSSStyleSheet</a></code> instance object).</li>
1008-
<li><p>Insert rule <var>newRule</var> into <code>cssRules</code> at the zero-indexed position <var>index</var>.<p></li>
1009-
<li><p>Return <var>index</var>.</li>
1010-
</ol>
1011-
<p class="note">If a new rule is inserted, then any rule previously located at position <var>index</var> through
1012-
<var>N</var> minus 1 is shifted to position <var>index</var> plus 1 through <var>N</var>,
1013-
In addition, <code>cssRules.length</code> is (internally) incremented.</p>
1014-
<p class="XXX">DOM-2 CSS specifies that a <code>NO_MODIFICATION_ALLOWED_ERR</code> exception is thrown
1015-
if the style sheet is read-only. Are there any read-only style sheets?</p>
993+
<p>The <dfn id="dom-cssstylesheet-insertrule" title="dom-CSSStyleSheet-insertRule"><code>insertRule(<var>rule</var>, <var>index</var>)</code></dfn> method must <a href="#insert-a-css-rule">insert a CSS rule</a>
994+
<var>rule</var> in the CSS rule list returned by <code title="dom-CSSStyleSheet-cssRules"><a href="#dom-cssstylesheet-cssrules">cssRules</a></code> at <var>index</var>.
1016995

1017-
<p>The <dfn id="dom-cssstylesheet-deleterule" title="dom-CSSStyleSheet-deleteRule"><code>deleteRule(<var>index</var>)</code></dfn> method performs <dfn id="remove-a-css-rule">remove a CSS rule</dfn> as follows:</p>
1018-
<ol>
1019-
<li><p>Set <var>N</var> to <code>cssLength.length</code>.</li>
1020-
<li><p>If argument <var>index</var> is greater than or equal to <var>N</var>, then <a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a>
1021-
an <code class="external"><a href="http://dom.spec.whatwg.org/#indexsizeerror">IndexSizeError</a></code> exception.</li>
1022-
<li><p>Set <var>oldRule</var> to <code>cssRules.prototype.item(<var>index</var>)</code>.</li>
1023-
<li><p>Set <var>oldRule</var><code>.parentStyleSheet</code> to <code>null</code>.</li>
1024-
<li><p>Remove rule <var>oldRule</var> from <code>cssRules</code> at the zero-indexed position <var>index</var>.<p></li>
1025-
</ol>
1026-
<p class="note">If an existing rule is deleted, then any rule previously located at position <var>index</var> plus 1 through
1027-
<var>N</var> minus 1 is shifted to position <var>index</var> through <var>N</var> minus 2,
1028-
In addition, <code>cssRules.length</code> is (internally) decremented.</p>
996+
<p>The <dfn id="dom-cssstylesheet-deleterule" title="dom-CSSStyleSheet-deleteRule"><code>deleteRule(<var>index</var>)</code></dfn> method must <a href="#remove-a-css-rule">remove a CSS rule</a> in the CSS rule list
997+
returned by <code title="dom-CSSStyleSheet-cssRules"><a href="#dom-cssstylesheet-cssrules">cssRules</a></code> at <var>index</var>.
1029998

1030999
<h3 id="style-sheet-collections"><span class="secno">6.2 </span>Style Sheet Collections</h3>
10311000

@@ -1754,6 +1723,35 @@ <h3 id="css-rules"><span class="secno">6.4 </span>CSS Rules</h3>
17541723
attribute, followed the character "<code>;</code>" (U+003B).</dd>
17551724
</dl>
17561725

1726+
<p>To <dfn id="insert-a-css-rule">insert a CSS rule</dfn> <var>rule</var> in a CSS rule list <var>list</var> at index <var>index</var>, follow these steps:</p>
1727+
<ol>
1728+
<li><p>Set <var>newRule</var> to the results of performing <a href="#parse-a-css-rule">parse a CSS rule</a>
1729+
on argument <var>rule</var>, <a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throwing</a>
1730+
a <code class="external"><a href="http://dom.spec.whatwg.org/#syntaxerror">SyntaxError</a></code> exception if a parse error occurs.</li>
1731+
<li><p>If <var title="">newRule</var> is an <code title="">@charset</code> at-rule, <a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> a
1732+
<code class="external"><a href="http://dom.spec.whatwg.org/#syntaxerror">SyntaxError</a></code> exception.
1733+
<li><p>Set <var>N</var> to the number of items in <var>list</var>.</li>
1734+
<li><p>If <var>index</var> is greater than <var>N</var>, then <a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a>
1735+
an <code class="external"><a href="http://dom.spec.whatwg.org/#indexsizeerror">IndexSizeError</a></code> exception.</li>
1736+
<li><p>If <var>newRule</var> cannot be inserted into <var>list</var> at the zero-index position <var>index</var> due to constraints specified
1737+
by CSS, then <a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a>
1738+
a <code class="external"><a href="http://dom.spec.whatwg.org/#hierarchyrequesterror">HierarchyRequestError</a></code> exception. <a href="#refsCSS">[CSS]</a></p>
1739+
<p class="note">For example, a CSS style sheet cannot contain an <code title="">@import</code> at-rule after a rule set.</li>
1740+
<li><p>Insert <var>newRule</var> into <var>list</var> at the zero-indexed position <var>index</var>.<p></li>
1741+
<li><p>Return <var>index</var>.</li>
1742+
</ol>
1743+
<p class="XXX">DOM-2 CSS specifies that a <code>NO_MODIFICATION_ALLOWED_ERR</code> exception is thrown
1744+
if the style sheet is read-only. Are there any read-only style sheets?</p>
1745+
1746+
<p>To <dfn id="remove-a-css-rule">remove a CSS rule</dfn> from a CSS rule list <var>list</var> at index <var>index</var>, follow these steps:</p>
1747+
<ol>
1748+
<li><p>Set <var>N</var> to the number of items in <var>list</var>.</li>
1749+
<li><p>If <var>index</var> is greater than or equal to <var>N</var>, then <a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a>
1750+
an <code class="external"><a href="http://dom.spec.whatwg.org/#indexsizeerror">IndexSizeError</a></code> exception.</li>
1751+
<li><p>Set <var>oldRule</var> to the <var>index</var>th item in <var>list</var>.</li>
1752+
<li><p>Remove rule <var>oldRule</var> from <var>list</var> at the zero-indexed position <var>index</var>.<p></li>
1753+
</ol>
1754+
17571755

17581756
<h4 id="the-cssrulelist-interface"><span class="secno">6.4.1 </span>The <code title="">CSSRuleList</code> Interface</h4>
17591757

@@ -1846,13 +1844,9 @@ <h4 id="the-cssrule-interface"><span class="secno">6.4.2 </span>The <code title=
18461844

18471845
<p>The <dfn id="dom-cssrule-parentstylesheet" title="dom-CSSRule-parentStyleSheet"><code>parentStyleSheet</code></dfn> attribute must return the <code><a href="#cssstylesheet">CSSStyleSheet</a></code> object that contains the the
18481846
current rule or <code>null</code> if there is none.</p>
1849-
<p class="note">The only circumstance where <code>null</code> is returned is in the case that
1850-
<code>CSSStyleSheet.prototype.deleteRule</code> has been invoked to <a href="#remove-a-css-rule">remove a CSS rule</a>
1851-
from a CSS style sheet, in which case its <code>parentStyleSheet</code> property will have been set to <code>null</code>.</p>
1852-
<p class="note">Removing an <code>Node</code> that implements the <code><a href="#linkstyle">LinkStyle</a></code> interface from a <code>Document</code> instance
1853-
does not (by itself) cause the <code><a href="#cssstylesheet">CSSStyleSheet</a></code> referenced by a <code><a href="#cssrule">CSSRule</a></code> to be unreachable; that is, as long as
1854-
there exists a reachable reference to a <code><a href="#cssrule">CSSRule</a></code> object, then its <code>parentStyleSheet</code> property remains viable
1855-
if it has not been previously removed from the style sheet by using the <code>deleteRule</code> operation.</p>
1847+
<p class="note">The only circumstance where <code>null</code> is returned when a rule has been <a href="#remove-a-css-rule" title="remove a CSS rule">removed</a>.</p>
1848+
<p class="note">Removing a <code>Node</code> that implements the <code><a href="#linkstyle">LinkStyle</a></code> interface from a <code>Document</code> instance
1849+
does not (by itself) cause the <code><a href="#cssstylesheet">CSSStyleSheet</a></code> referenced by a <code><a href="#cssrule">CSSRule</a></code> to be unreachable.</p>
18561850

18571851

18581852
<h4 id="the-cssstylerule-interface"><span class="secno">6.4.3 </span>The <code title="">CSSStyleRule</code> Interface</h4>

cssom/Overview.src.html

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -920,42 +920,11 @@ <h4>The <code title>CSSStyleSheet</code> Interface</h4>
920920
client-authored script), it can nevertheless change over time due to its liveness status. For example, invoking
921921
the <code title=dom-CSSStyleSheet-insertRule>insertRule()</code> or <code title=dom-CSSStyleSheet-deleteRule>deleteRule()</code> methods can result in mutations reflected in the returned object.</p>
922922

923-
<p>The <dfn title=dom-CSSStyleSheet-insertRule><code>insertRule(<var>rule</var>, <var>index</var>)</code></dfn> method performs <dfn>insert a CSS rule</dfn> <var>rule</var> as follows:</p>
924-
<ol>
925-
<li><p>Set <var>newRule</var> to the results of performing <span>parse a CSS rule</span>
926-
on argument <var>rule</var>, <span data-anolis-spec='dom' title='concept-throw'>throwing</span>
927-
a <code data-anolis-spec='dom'>SyntaxError</code> exception if a parse error occurs.</p></li>
928-
<li><p>If <var title>newRule</var> is an <code title>@charset</code> at-rule, <span data-anolis-spec='dom' title='concept-throw'>throw</span> a
929-
<code data-anolis-spec='dom'>SyntaxError</code> exception.
930-
<li><p>Set <var>N</var> to <code>cssLength.length</code>.</p></li>
931-
<li><p>If argument <var>index</var> is greater than <var>N</var>, then <span data-anolis-spec='dom' title='concept-throw'>throw</span>
932-
an <code data-anolis-spec='dom'>IndexSizeError</code> exception.</p></li>
933-
<li><p>If the rule <var>newRule</var> cannot be inserted into the specified <var>index</var> due to constraints specified
934-
by <span data-anolis-ref>CSS</span>, then <span data-anolis-spec='dom' title='concept-throw'>throw</span>
935-
a <code data-anolis-spec='dom'>HierarchyRequestError</code> exception.</p>
936-
<p class='note'>For example, a CSS style sheet cannot contain an <code title>@import</code> at-rule after a rule set.</p></li>
937-
<li><p>Set <var>newRule</var><code>.parentStyleSheet</code> to <code>this</code> (i.e., this <code>CSSStyleSheet</code> instance object).</p></li>
938-
<li><p>Insert rule <var>newRule</var> into <code>cssRules</code> at the zero-indexed position <var>index</var>.<p></li>
939-
<li><p>Return <var>index</var>.</p></li>
940-
</ol>
941-
<p class='note'>If a new rule is inserted, then any rule previously located at position <var>index</var> through
942-
<var>N</var> minus 1 is shifted to position <var>index</var> plus 1 through <var>N</var>,
943-
In addition, <code>cssRules.length</code> is (internally) incremented.</p>
944-
<p class='XXX'>DOM-2 CSS specifies that a <code>NO_MODIFICATION_ALLOWED_ERR</code> exception is thrown
945-
if the style sheet is read-only. Are there any read-only style sheets?</p>
923+
<p>The <dfn title=dom-CSSStyleSheet-insertRule><code>insertRule(<var>rule</var>, <var>index</var>)</code></dfn> method must <span>insert a CSS rule</span>
924+
<var>rule</var> in the CSS rule list returned by <code title=dom-CSSStyleSheet-cssRules>cssRules</code> at <var>index</var>.
946925

947-
<p>The <dfn title=dom-CSSStyleSheet-deleteRule><code>deleteRule(<var>index</var>)</code></dfn> method performs <dfn>remove a CSS rule</dfn> as follows:</p>
948-
<ol>
949-
<li><p>Set <var>N</var> to <code>cssLength.length</code>.</p></li>
950-
<li><p>If argument <var>index</var> is greater than or equal to <var>N</var>, then <span data-anolis-spec='dom' title='concept-throw'>throw</span>
951-
an <code data-anolis-spec='dom'>IndexSizeError</code> exception.</p></li>
952-
<li><p>Set <var>oldRule</var> to <code>cssRules.prototype.item(<var>index</var>)</code>.</p></li>
953-
<li><p>Set <var>oldRule</var><code>.parentStyleSheet</code> to <code>null</code>.</p></li>
954-
<li><p>Remove rule <var>oldRule</var> from <code>cssRules</code> at the zero-indexed position <var>index</var>.<p></li>
955-
</ol>
956-
<p class='note'>If an existing rule is deleted, then any rule previously located at position <var>index</var> plus 1 through
957-
<var>N</var> minus 1 is shifted to position <var>index</var> through <var>N</var> minus 2,
958-
In addition, <code>cssRules.length</code> is (internally) decremented.</p>
926+
<p>The <dfn title=dom-CSSStyleSheet-deleteRule><code>deleteRule(<var>index</var>)</code></dfn> method must <span>remove a CSS rule</span> in the CSS rule list
927+
returned by <code title=dom-CSSStyleSheet-cssRules>cssRules</code> at <var>index</var>.
959928

960929
<h3>Style Sheet Collections</h3>
961930

@@ -1684,6 +1653,35 @@ <h3>CSS Rules</h3>
16841653
attribute, followed the character "<code>;</code>" (U+003B).</p></dd>
16851654
</dl>
16861655

1656+
<p>To <dfn>insert a CSS rule</dfn> <var>rule</var> in a CSS rule list <var>list</var> at index <var>index</var>, follow these steps:</p>
1657+
<ol>
1658+
<li><p>Set <var>newRule</var> to the results of performing <span>parse a CSS rule</span>
1659+
on argument <var>rule</var>, <span data-anolis-spec='dom' title='concept-throw'>throwing</span>
1660+
a <code data-anolis-spec='dom'>SyntaxError</code> exception if a parse error occurs.</p></li>
1661+
<li><p>If <var title>newRule</var> is an <code title>@charset</code> at-rule, <span data-anolis-spec='dom' title='concept-throw'>throw</span> a
1662+
<code data-anolis-spec='dom'>SyntaxError</code> exception.
1663+
<li><p>Set <var>N</var> to the number of items in <var>list</var>.</p></li>
1664+
<li><p>If <var>index</var> is greater than <var>N</var>, then <span data-anolis-spec='dom' title='concept-throw'>throw</span>
1665+
an <code data-anolis-spec='dom'>IndexSizeError</code> exception.</p></li>
1666+
<li><p>If <var>newRule</var> cannot be inserted into <var>list</var> at the zero-index position <var>index</var> due to constraints specified
1667+
by CSS, then <span data-anolis-spec='dom' title='concept-throw'>throw</span>
1668+
a <code data-anolis-spec='dom'>HierarchyRequestError</code> exception. <span data-anolis-ref>CSS</span></p>
1669+
<p class='note'>For example, a CSS style sheet cannot contain an <code title>@import</code> at-rule after a rule set.</p></li>
1670+
<li><p>Insert <var>newRule</var> into <var>list</var> at the zero-indexed position <var>index</var>.<p></li>
1671+
<li><p>Return <var>index</var>.</p></li>
1672+
</ol>
1673+
<p class='XXX'>DOM-2 CSS specifies that a <code>NO_MODIFICATION_ALLOWED_ERR</code> exception is thrown
1674+
if the style sheet is read-only. Are there any read-only style sheets?</p>
1675+
1676+
<p>To <dfn>remove a CSS rule</dfn> from a CSS rule list <var>list</var> at index <var>index</var>, follow these steps:</p>
1677+
<ol>
1678+
<li><p>Set <var>N</var> to the number of items in <var>list</var>.</p></li>
1679+
<li><p>If <var>index</var> is greater than or equal to <var>N</var>, then <span data-anolis-spec='dom' title='concept-throw'>throw</span>
1680+
an <code data-anolis-spec='dom'>IndexSizeError</code> exception.</p></li>
1681+
<li><p>Set <var>oldRule</var> to the <var>index</var>th item in <var>list</var>.</p></li>
1682+
<li><p>Remove rule <var>oldRule</var> from <var>list</var> at the zero-indexed position <var>index</var>.<p></li>
1683+
</ol>
1684+
16871685

16881686
<h4>The <code title>CSSRuleList</code> Interface</h4>
16891687

@@ -1776,13 +1774,9 @@ <h4>The <code title>CSSRule</code> Interface</h4>
17761774

17771775
<p>The <dfn title=dom-CSSRule-parentStyleSheet><code>parentStyleSheet</code></dfn> attribute must return the <code>CSSStyleSheet</code> object that contains the the
17781776
current rule or <code>null</code> if there is none.</p>
1779-
<p class='note'>The only circumstance where <code>null</code> is returned is in the case that
1780-
<code>CSSStyleSheet.prototype.deleteRule</code> has been invoked to <span>remove a CSS rule</span>
1781-
from a CSS style sheet, in which case its <code>parentStyleSheet</code> property will have been set to <code>null</code>.</p>
1782-
<p class='note'>Removing an <code>Node</code> that implements the <code>LinkStyle</code> interface from a <code>Document</code> instance
1783-
does not (by itself) cause the <code>CSSStyleSheet</code> referenced by a <code>CSSRule</code> to be unreachable; that is, as long as
1784-
there exists a reachable reference to a <code>CSSRule</code> object, then its <code>parentStyleSheet</code> property remains viable
1785-
if it has not been previously removed from the style sheet by using the <code>deleteRule</code> operation.</p>
1777+
<p class='note'>The only circumstance where <code>null</code> is returned when a rule has been <span title="remove a CSS rule">removed</span>.</p>
1778+
<p class='note'>Removing a <code>Node</code> that implements the <code>LinkStyle</code> interface from a <code>Document</code> instance
1779+
does not (by itself) cause the <code>CSSStyleSheet</code> referenced by a <code>CSSRule</code> to be unreachable.</p>
17861780

17871781

17881782
<h4>The <code title>CSSStyleRule</code> Interface</h4>

0 commit comments

Comments
 (0)