Skip to content

Commit dc7409c

Browse files
committed
implement removing and replacing css statements
1 parent 3f020cd commit dc7409c

2 files changed

Lines changed: 101 additions & 51 deletions

File tree

cssom/Overview.html

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,44 @@ <h3 id=processing><span class=secno>3.1. </span>Processing CSS Statements</h3>
11441144
<li>Insert <var>object</var> at the given <var>index</var> within the
11451145
<var>rule list</var>.
11461146
</ol>
1147+
1148+
<p>The rules for <dfn id=removing title="remove a statement">removing a
1149+
statement</dfn> are as given in the following algorithm. The variables
1150+
<var>index</var> and <var>rule list</var> are to be considered equivalent
1151+
to the identically named variables used when invoking this algorithm. If
1152+
an exception is raised this algorithm is to be aborted. The steps <em
1153+
class=ct>must</em> be followed in order, as follows:
1154+
1155+
<ol>
1156+
<li>If <var>index</var> is negative or greater than the length of the
1157+
<var>rule list</var> an <code>INDEX_SIZE_ERR</code> exception <em
1158+
class=ct>must</em> be raised.
1159+
1160+
<li>Remove the object at <var>index</var> from <var>rule list</var>.
1161+
</ol>
1162+
1163+
<p>The rules for <dfn id=replacing title="replace a statement">replacing a
1164+
statement</dfn> are as given in the following algorithm. The variable
1165+
<var>rule</var> and <var>old object</var> are to be considered equivalent
1166+
to the identically named variables used when invoking this algorithm. If
1167+
an exception is raised this algorithm is to be aborted. The steps <em
1168+
class=ct>must</em> be followed in order, as follows:
1169+
1170+
<ol>
1171+
<li>Parse <var>rule</var> as a CSS statement. If the <var>rule</var> is
1172+
ignored by the CSS parser abort this algorithm (don't raise an
1173+
exception). Otherwise, create an object that implements one of the
1174+
inherited interfaces of <code>CSSStyle</code> appropriate for the parsed
1175+
<var>rule</var>. Let <var>object</var> be the newly created object.
1176+
1177+
<li>If the <code title=cssrule-type><a
1178+
href="#cssrule-type">type</a></code> of new <var>object</var> doesn't
1179+
match the <code title=cssrule-type><a
1180+
href="#cssrule-type">type</a></code> of the object it will replace raise
1181+
an <code>INVALID_MODIFICATION_ERR</code> exception.
1182+
1183+
<li>Replace <var>old object</var> with <var>object</var>.
1184+
</ol>
11471185
<!-- XXX we should probably also detail how a CSSStyleRule is properly done
11481186
et cetera. -->
11491187

@@ -1210,12 +1248,11 @@ <h3 id=the-cssstylesheet><span class=secno>3.2. </span>The <code><a
12101248
title=cssstylesheet-deleterule><code>deleteRule(<var
12111249
title="">index</var>)</code></dfn>, method
12121250

1213-
<dd>When invoked, if <var title="">index</var> is negative or greather
1214-
than the <code title=cssrulelist-length><a
1215-
href="#cssrulelist-length">length</a></code> user agents <em
1216-
class=ct>must</em> raise a <code>INDEX_SIZE_ERR</code> exception.
1217-
Otherwise user agents <em class=ct>must</em> remove the rule given by
1218-
<var title="">index</var>.
1251+
<dd>When invoked, user agents <em class=ct>must</em> <a
1252+
href="#removing">remove a statement</a> where <var>index</var> is
1253+
<var>index</var> and <var>rule list</var> is <code
1254+
title=cssmediarule-cssrules><a
1255+
href="#cssmediarule-cssrules"><code>cssRules</code>.</a></code>
12191256
</dl>
12201257

12211258
<h3 id=the-cssrulelist><span class=secno>3.3. </span>The <code><a
@@ -1305,25 +1342,14 @@ <h4 id=the-cssrule><span class=secno>3.4.1. </span>The <code><a
13051342

13061343
<dt><dfn id=cssrule-csstext
13071344
title=cssrule-csstext><code>cssText</code></dfn> of type
1308-
<code>DOMString</code></dt>
1309-
<!-- Setting this attribute doesn't work in Firefox. -->
1345+
<code>DOMString</code>
13101346

13111347
<dd>
1312-
<p>On setting, user agents <em class=ct>must</em> parse the given string
1313-
as a statement. If the given statement was ignored user agents <em
1314-
class=ct>must</em> act as if the setting didn't occur.</p>
1315-
1316-
<p>Otherwise, if the <code title=cssrule-type><a
1317-
href="#cssrule-type">type</a></code> of the resulting <code><a
1318-
href="#cssrule">CSSRule</a></code> object doesn't match the current
1319-
<code title=cssrule-type><a href="#cssrule-type">type</a></code> a
1320-
<code>INVALID_MODIFICATION_ERR</code> exception <em class=ct>must</em>
1321-
be raised.</p>
1322-
1323-
<p>Otherwise, <span class=issue>...</span>.</p>
1324-
<!-- XXX Need to make sure the underlying object has all its relevant
1325-
attributes modified. -->
1326-
1348+
<p>On setting, user agents <em class=ct>must</em> <a
1349+
href="#replacing">replace a statement</a> where <var>rule</var> is the
1350+
value being set and <var>old object</var> is the object of which this
1351+
attribute is set.</p>
1352+
13271353
<p>On getting, <span class=issue>...</span>.</p>
13281354

13291355
<dt><dfn id=cssrule-parentrule
@@ -1496,10 +1522,11 @@ <h4 id=the-cssmediarule><span class=secno>3.4.5. </span>The <code><a
14961522
title=cssmediarule-deleterule><code>deleteRule(<var
14971523
title="">index</var>)</code></dfn>, method
14981524

1499-
<dd>This method <em class=ct>must</em> raise a <code>INDEX_SIZE_ERR</code>
1500-
exception if the given <var>index</var> does not correspond to a rule in
1501-
the style sheet. Otherwise, it <em class=ct>must</em> remove the rule at
1502-
<var>index</var>.
1525+
<dd>When invoked, user agents <em class=ct>must</em> <a
1526+
href="#removing">remove a statement</a> where <var>index</var> is
1527+
<var>index</var> and <var>rule list</var> is <code
1528+
title=cssmediarule-cssrules><a
1529+
href="#cssmediarule-cssrules"><code>cssRules</code>.</a></code>
15031530
</dl>
15041531

15051532
<h4 id=the-cssfontfacerule><span class=secno>3.4.6. </span>The <code><a

cssom/Overview.src.html

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,42 @@ <h3>Processing CSS Statements</h3>
828828
<var>rule list</var>.</li>
829829
</ol>
830830

831+
<p>The rules for <dfn title="remove a statement">removing a statement</dfn>
832+
are as given in the following algorithm. The variables <var>index</var> and
833+
<var>rule list</var> are to be considered equivalent to the identically
834+
named variables used when invoking this algorithm. If an exception is raised
835+
this algorithm is to be aborted. The steps <em class="ct">must</em> be
836+
followed in order, as follows:</p>
837+
838+
<ol>
839+
<li>If <var>index</var> is negative or greater than the length of the
840+
<var>rule list</var> an <code>INDEX_SIZE_ERR</code> exception
841+
<em class="ct">must</em> be raised.</li>
842+
843+
<li>Remove the object at <var>index</var> from <var>rule list</var>.</li>
844+
</ol>
845+
846+
<p>The rules for <dfn title="replace a statement">replacing a
847+
statement</dfn> are as given in the following algorithm. The variable
848+
<var>rule</var> and <var>old object</var> are to be considered equivalent to
849+
the identically named variables used when invoking this algorithm. If an
850+
exception is raised this algorithm is to be aborted. The steps
851+
<em class="ct">must</em> be followed in order, as follows:</p>
852+
853+
<ol>
854+
<li>Parse <var>rule</var> as a CSS statement. If the <var>rule</var> is
855+
ignored by the CSS parser abort this algorithm (don't raise an exception).
856+
Otherwise, create an object that implements one of the inherited interfaces
857+
of <code>CSSStyle</code> appropriate for the parsed <var>rule</var>. Let
858+
<var>object</var> be the newly created object.</li>
859+
860+
<li>If the <code title="cssrule-type">type</code> of new <var>object</var>
861+
doesn't match the <code title="cssrule-type">type</code> of the object it
862+
will replace raise an <code>INVALID_MODIFICATION_ERR</code> exception.</li>
863+
864+
<li>Replace <var>old object</var> with <var>object</var>.</li>
865+
</ol>
866+
831867
<!-- XXX we should probably also detail how a CSSStyleRule is properly done
832868
et cetera. -->
833869

@@ -890,11 +926,10 @@ <h3>The <code>CSSStyleSheet</code> Interface</h3>
890926
<dt><dfn id="cssstylesheet-deleterule" title="cssstylesheet-deleterule"><code>deleteRule(<var title="">index</var>)</code></dfn>,
891927
method</dt>
892928

893-
<dd>When invoked, if <var title="">index</var> is negative or greather than
894-
the <code title="cssrulelist-length">length</code> user agents
895-
<em class="ct">must</em> raise a <code>INDEX_SIZE_ERR</code> exception.
896-
Otherwise user agents <em class="ct">must</em> remove the rule given by
897-
<var title="">index</var>.</dd>
929+
<dd>When invoked, user agents <em class="ct">must</em> <span>remove a
930+
statement</span> where <var>index</var> is <var>index</var> and <var>rule
931+
list</var> is
932+
<code title="cssmediarule-cssrules"><code>cssRules</code>.</dd>
898933
</dl>
899934

900935
<h3>The <code>CSSRuleList</code> Interface</h3>
@@ -975,22 +1010,11 @@ <h4>The <code>CSSRule</code> Interface</h4>
9751010

9761011
<dt><dfn id="cssrule-csstext" title="cssrule-csstext"><code>cssText</code></dfn>
9771012
of type <code>DOMString</code></dt>
978-
<!-- Setting this attribute doesn't work in Firefox. -->
9791013

9801014
<dd>
981-
<p>On setting, user agents <em class="ct">must</em> parse the given string
982-
as a statement. If the given statement was ignored user agents
983-
<em class="ct">must</em> act as if the setting didn't occur.</p>
984-
985-
<p>Otherwise, if the <code title="cssrule-type">type</code> of the
986-
resulting <code>CSSRule</code> object doesn't match the current
987-
<code title="cssrule-type">type</code> a
988-
<code>INVALID_MODIFICATION_ERR</code> exception <em class="ct">must</em> be
989-
raised.</p>
990-
991-
<p>Otherwise, <span class="issue">...</span>.</p>
992-
<!-- XXX Need to make sure the underlying object has all its relevant
993-
attributes modified. -->
1015+
<p>On setting, user agents <em class="ct">must</em> <span>replace a
1016+
statement</span> where <var>rule</var> is the value being set and <var>old
1017+
object</var> is the object of which this attribute is set.</p>
9941018

9951019
<p>On getting, <span class="issue">...</span>.</p>
9961020
</dd>
@@ -1146,11 +1170,10 @@ <h4>The <code>CSSMediaRule</code> Interface</h4>
11461170
<dt><dfn id="cssmediarule-deleterule" title="cssmediarule-deleterule"><code>deleteRule(<var title="">index</var>)</code></dfn>,
11471171
method</dt>
11481172

1149-
<dd>This method <em class="ct">must</em> raise a
1150-
<code>INDEX_SIZE_ERR</code> exception if the given <var>index</var> does
1151-
not correspond to a rule in the style sheet. Otherwise, it
1152-
<em class="ct">must</em> remove the rule at <var>index</var>.</dd>
1153-
1173+
<dd>When invoked, user agents <em class="ct">must</em> <span>remove a
1174+
statement</span> where <var>index</var> is <var>index</var> and <var>rule
1175+
list</var> is
1176+
<code title="cssmediarule-cssrules"><code>cssRules</code>.</dd>
11541177
</dl>
11551178

11561179
<h4>The <code>CSSFontFaceRule</code> Interface</h4>

0 commit comments

Comments
 (0)