Skip to content

Commit 8849a8e

Browse files
author
Simon Pieters
committed
[cssom] Disallow changes to @namespace if there are other rules, and allow changes otherwise. https://www.w3.org/Bugs/Public/show_bug.cgi?id=22208
1 parent 414f264 commit 8849a8e

2 files changed

Lines changed: 60 additions & 8 deletions

File tree

cssom/Overview.html

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,6 +1737,9 @@ <h3 id="css-rules"><span class="secno">6.4 </span>CSS Rules</h3>
17371737
by CSS, then <a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a>
17381738
a <code class="external"><a href="http://dom.spec.whatwg.org/#hierarchyrequesterror">HierarchyRequestError</a></code> exception. <a href="#refsCSS">[CSS]</a></p>
17391739
<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>If <var title="">newRule</var> is an <code title="">@namespace</code> at-rule, and <var title="">list</var> contains anything other than
1741+
<code title="">@charset</code> at-rules, <code title="">@import</code> at-rules, and <code title="">@namespace</code> at-rules,
1742+
<a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> an <code class="external"><a href="http://dom.spec.whatwg.org/#invalidstateerror">InvalidStateError</a></code> exception.
17401743
<li><p>Insert <var>newRule</var> into <var>list</var> at the zero-indexed position <var>index</var>.<p></li>
17411744
<li><p>Return <var>index</var>.</li>
17421745
</ol>
@@ -1749,6 +1752,9 @@ <h3 id="css-rules"><span class="secno">6.4 </span>CSS Rules</h3>
17491752
<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>
17501753
an <code class="external"><a href="http://dom.spec.whatwg.org/#indexsizeerror">IndexSizeError</a></code> exception.</li>
17511754
<li><p>Set <var>oldRule</var> to the <var>index</var>th item in <var>list</var>.</li>
1755+
<li><p>If <var title="">oldRule</var> is an <code title="">@namespace</code> at-rule, and <var title="">list</var> contains anything other than
1756+
<code title="">@charset</code> at-rules, <code title="">@import</code> at-rules, and <code title="">@namespace</code> at-rules,
1757+
<a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> an <code class="external"><a href="http://dom.spec.whatwg.org/#invalidstateerror">InvalidStateError</a></code> exception.
17521758
<li><p>Remove rule <var>oldRule</var> from <var>list</var> at the zero-indexed position <var>index</var>.<p></li>
17531759
</ol>
17541760

@@ -1976,15 +1982,35 @@ <h4 id="the-cssnamespacerule-interface"><span class="secno">6.4.9 </span>The <co
19761982
<p>The <code><a href="#cssnamespacerule">CSSNamespaceRule</a></code> interface represents a <code>@namespace</code> rule.</p>
19771983

19781984
<pre class="idl">interface <dfn id="cssnamespacerule">CSSNamespaceRule</dfn> : <a href="#cssrule">CSSRule</a> {
1979-
readonly attribute DOMString namespaceURI;
1980-
readonly attribute DOMString? prefix;<!-- XXX not nullable? -->
1985+
[TreatNullAs=EmptyString] attribute DOMString namespaceURI;
1986+
[TreatNullAs=EmptyString] attribute DOMString prefix;
19811987
};</pre>
19821988

1983-
<p>The <dfn id="dom-cssnamespacerule-namespaceuri" title="dom-CSSNamespaceRule-namespaceURI"><code>namespaceURI</code></dfn> attribute must return the namespace of the <code>@namespace</code> rule.</p>
1989+
<p>The <dfn id="dom-cssnamespacerule-namespaceuri" title="dom-CSSNamespaceRule-namespaceURI"><code>namespaceURI</code></dfn> attribute, on getting, must return the namespace of the
1990+
<code>@namespace</code> rule. On setting, the <code title="dom-CSSNamespaceRule-namespaceURI"><a href="#dom-cssnamespacerule-namespaceuri">namespaceURI</a></code> attribute must run the following steps:</p>
1991+
1992+
<ol>
1993+
<li><p>Let <var title="">style sheet</var> be the value returned by <code title="dom-CSSRule-parentStyleSheet"><a href="#dom-cssrule-parentstylesheet">parentStyleSheet</a></code>.
1994+
<li><p>Let <var title="">list</var> be the value returned by <code title="dom-CSSStyleSheet-cssRules"><a href="#dom-cssstylesheet-cssrules">cssRules</a></code> of <var title="">style sheet</var>, or
1995+
<code title="">null</code> if <var title="">style sheet</var> is <code title="">null</code>.
1996+
<li><p>If <var title="">list</var> is not <code title="">null</code> and contains anything other than
1997+
<code title="">@charset</code> at-rules, <code title="">@import</code> at-rules, and <code title="">@namespace</code> at-rules,
1998+
<a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> an <code class="external"><a href="http://dom.spec.whatwg.org/#invalidstateerror">InvalidStateError</a></code> exception.
1999+
<li><p>Set the namespace of the <code title="">@namespace</code> at-rule to the given value.
2000+
</ol>
19842001

19852002
<p>The <dfn id="dom-cssnamespacerule-prefix" title="dom-CSSNamespaceRule-prefix"><code>prefix</code></dfn> attribute must return the prefix of the <code>@namespace</code> rule or the
1986-
empty string if there is no prefix.</p>
2003+
empty string if there is no prefix. On setting, the <code title="dom-CSSNamespaceRule-prefix"><a href="#dom-cssnamespacerule-prefix">prefix</a></code> attribute must run the following steps:</p>
19872004

2005+
<ol>
2006+
<li><p>Let <var title="">style sheet</var> be the value returned by <code title="dom-CSSRule-parentStyleSheet"><a href="#dom-cssrule-parentstylesheet">parentStyleSheet</a></code>.
2007+
<li><p>Let <var title="">list</var> be the value returned by <code title="dom-CSSStyleSheet-cssRules"><a href="#dom-cssstylesheet-cssrules">cssRules</a></code> of <var title="">style sheet</var>, or
2008+
<code title="">null</code> if <var title="">style sheet</var> is <code title="">null</code>.
2009+
<li><p>If <var title="">list</var> is not <code title="">null</code> and contains anything other than
2010+
<code title="">@charset</code> at-rules, <code title="">@import</code> at-rules, and <code title="">@namespace</code> at-rules,
2011+
<a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> an <code class="external"><a href="http://dom.spec.whatwg.org/#invalidstateerror">InvalidStateError</a></code> exception.
2012+
<li><p>Set the prefix of the <code title="">@namespace</code> at-rule to the given value.
2013+
</ol>
19882014

19892015

19902016
<h3 id="css-declaration-blocks"><span class="secno">6.5 </span>CSS Declaration Blocks</h3>

cssom/Overview.src.html

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,9 @@ <h3>CSS Rules</h3>
16671667
by CSS, then <span data-anolis-spec='dom' title='concept-throw'>throw</span>
16681668
a <code data-anolis-spec='dom'>HierarchyRequestError</code> exception. <span data-anolis-ref>CSS</span></p>
16691669
<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>If <var title>newRule</var> is an <code title>@namespace</code> at-rule, and <var title>list</var> contains anything other than
1671+
<code title>@charset</code> at-rules, <code title>@import</code> at-rules, and <code title>@namespace</code> at-rules,
1672+
<span data-anolis-spec='dom' title='concept-throw'>throw</span> an <code data-anolis-spec=dom>InvalidStateError</code> exception.
16701673
<li><p>Insert <var>newRule</var> into <var>list</var> at the zero-indexed position <var>index</var>.<p></li>
16711674
<li><p>Return <var>index</var>.</p></li>
16721675
</ol>
@@ -1679,6 +1682,9 @@ <h3>CSS Rules</h3>
16791682
<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>
16801683
an <code data-anolis-spec='dom'>IndexSizeError</code> exception.</p></li>
16811684
<li><p>Set <var>oldRule</var> to the <var>index</var>th item in <var>list</var>.</p></li>
1685+
<li><p>If <var title>oldRule</var> is an <code title>@namespace</code> at-rule, and <var title>list</var> contains anything other than
1686+
<code title>@charset</code> at-rules, <code title>@import</code> at-rules, and <code title>@namespace</code> at-rules,
1687+
<span data-anolis-spec='dom' title='concept-throw'>throw</span> an <code data-anolis-spec=dom>InvalidStateError</code> exception.
16821688
<li><p>Remove rule <var>oldRule</var> from <var>list</var> at the zero-indexed position <var>index</var>.<p></li>
16831689
</ol>
16841690

@@ -1906,15 +1912,35 @@ <h4>The <code title>CSSNamespaceRule</code> Interface</h4>
19061912
<p>The <code>CSSNamespaceRule</code> interface represents a <code>@namespace</code> rule.</p>
19071913

19081914
<pre class=idl>interface <dfn>CSSNamespaceRule</dfn> : <span>CSSRule</span> {
1909-
readonly attribute DOMString namespaceURI;
1910-
readonly attribute DOMString? prefix;<!-- XXX not nullable? -->
1915+
[TreatNullAs=EmptyString] attribute DOMString namespaceURI;
1916+
[TreatNullAs=EmptyString] attribute DOMString prefix;
19111917
};</pre>
19121918

1913-
<p>The <dfn title=dom-CSSNamespaceRule-namespaceURI><code>namespaceURI</code></dfn> attribute must return the namespace of the <code>@namespace</code> rule.</p>
1919+
<p>The <dfn title=dom-CSSNamespaceRule-namespaceURI><code>namespaceURI</code></dfn> attribute, on getting, must return the namespace of the
1920+
<code>@namespace</code> rule. On setting, the <code title=dom-CSSNamespaceRule-namespaceURI>namespaceURI</code> attribute must run the following steps:</p>
1921+
1922+
<ol>
1923+
<li><p>Let <var title>style sheet</var> be the value returned by <code title=dom-CSSRule-parentStyleSheet>parentStyleSheet</code>.
1924+
<li><p>Let <var title>list</var> be the value returned by <code title=dom-CSSStyleSheet-cssRules>cssRules</code> of <var title>style sheet</var>, or
1925+
<code title>null</code> if <var title>style sheet</var> is <code title>null</code>.
1926+
<li><p>If <var title>list</var> is not <code title>null</code> and contains anything other than
1927+
<code title>@charset</code> at-rules, <code title>@import</code> at-rules, and <code title>@namespace</code> at-rules,
1928+
<span data-anolis-spec='dom' title='concept-throw'>throw</span> an <code data-anolis-spec=dom>InvalidStateError</code> exception.
1929+
<li><p>Set the namespace of the <code title>@namespace</code> at-rule to the given value.
1930+
</ol>
19141931

19151932
<p>The <dfn title=dom-CSSNamespaceRule-prefix><code>prefix</code></dfn> attribute must return the prefix of the <code>@namespace</code> rule or the
1916-
empty string if there is no prefix.</p>
1933+
empty string if there is no prefix. On setting, the <code title=dom-CSSNamespaceRule-prefix>prefix</code> attribute must run the following steps:</p>
19171934

1935+
<ol>
1936+
<li><p>Let <var title>style sheet</var> be the value returned by <code title=dom-CSSRule-parentStyleSheet>parentStyleSheet</code>.
1937+
<li><p>Let <var title>list</var> be the value returned by <code title=dom-CSSStyleSheet-cssRules>cssRules</code> of <var title>style sheet</var>, or
1938+
<code title>null</code> if <var title>style sheet</var> is <code title>null</code>.
1939+
<li><p>If <var title>list</var> is not <code title>null</code> and contains anything other than
1940+
<code title>@charset</code> at-rules, <code title>@import</code> at-rules, and <code title>@namespace</code> at-rules,
1941+
<span data-anolis-spec='dom' title='concept-throw'>throw</span> an <code data-anolis-spec=dom>InvalidStateError</code> exception.
1942+
<li><p>Set the prefix of the <code title>@namespace</code> at-rule to the given value.
1943+
</ol>
19181944

19191945

19201946
<h3>CSS Declaration Blocks</h3>

0 commit comments

Comments
 (0)