Skip to content

Commit 8047108

Browse files
author
Simon Pieters
committed
[cssom] Make setProperty do what dbaron wants. Introduce setPropertyValue and setPropertyPriority. https://www.w3.org/Bugs/Public/show_bug.cgi?id=23066
1 parent adc1428 commit 8047108

File tree

2 files changed

+158
-30
lines changed

2 files changed

+158
-30
lines changed

cssom/Overview.html

Lines changed: 80 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<h1>CSS Object Model (CSSOM)</h1>
1717

1818

19-
<h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 5 September 2013</h2>
19+
<h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 11 September 2013</h2>
2020

2121
<dl>
2222

@@ -90,7 +90,7 @@ <h2 class="no-num no-toc" id="sotd">Status of This Document</h2>
9090
can be found in the
9191
<a href="http://www.w3.org/TR/">W3C technical reports index at http://www.w3.org/TR/.</a></em>
9292

93-
<p class="dontpublish">This is the 5 September 2013 Editor's Draft of CSSOM. Please send comments to
93+
<p class="dontpublish">This is the 11 September 2013 Editor's Draft of CSSOM. Please send comments to
9494
<a href="mailto:www-style@w3.org?subject=%5Bcssom%5D%20">www-style@w3.org</a>
9595
(<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
9696
with <samp>[cssom]</samp> at the start of the subject line.
@@ -2256,7 +2256,7 @@ <h3 id="css-declaration-blocks"><span class="secno">6.6 </span>CSS Declaration B
22562256
<li><p>If <var>property</var> maps to one or more shorthand properties, let <var>shorthands</var> be an array of those shorthand properties, in
22572257
<a href="#concept-shorthands-preferred-order" title="concept-shorthands-preferred-order">preferred order</a>, and follow these substeps:
22582258
<ol>
2259-
<li><p>Let <var>longhands</var> an array consisting of all <a href="#css-declaration" title="CSS declaration">CSS declarations</a> in <var>declaration block</var>'s
2259+
<li><p>Let <var>longhands</var> be an array consisting of all <a href="#css-declaration" title="CSS declaration">CSS declarations</a> in <var>declaration block</var>'s
22602260
<a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a> that that are not in <var>already serialized</var> and have a
22612261
<a href="#concept-css-declaration-property-name" title="concept-css-declaration-property-name">property name</a> that
22622262
maps to one of the shorthand properties in <var>shorthands</var>.
@@ -2327,7 +2327,9 @@ <h4 id="the-cssstyledeclaration-interface"><span class="secno">6.6.1 </span>The
23272327
DOMString <a href="#dom-cssstyledeclaration-getpropertyvalue" title="dom-CSSStyleDeclaration-getPropertyValue">getPropertyValue</a>(DOMString property);
23282328
DOMString <a href="#dom-cssstyledeclaration-getpropertypriority" title="dom-CSSStyleDeclaration-getPropertyPriority">getPropertyPriority</a>(DOMString property);
23292329
void <a href="#dom-cssstyledeclaration-setproperty" title="dom-CSSStyleDeclaration-setProperty">setProperty</a>(DOMString property, [TreatNullAs=EmptyString] DOMString value, <!--
2330-
-->[TreatNullAs=EmptyString] optional DOMString priority);
2330+
-->[TreatNullAs=EmptyString] optional DOMString priority = "");
2331+
void <a href="#dom-cssstyledeclaration-setpropertyvalue" title="dom-CSSStyleDeclaration-setPropertyValue">setPropertyValue</a>(DOMString property, [TreatNullAs=EmptyString] DOMString value);
2332+
void <a href="#dom-cssstyledeclaration-setpropertypriority" title="dom-CSSStyleDeclaration-setPropertyPriority">setPropertyPriority</a>(DOMString property, [TreatNullAs=EmptyString] DOMString priority);
23312333
DOMString <a href="#dom-cssstyledeclaration-removeproperty" title="dom-CSSStyleDeclaration-removeProperty">removeProperty</a>(DOMString property);
23322334
readonly attribute <a href="#cssrule">CSSRule</a>? <a href="#dom-cssstyledeclaration-parentrule" title="dom-CSSStyleDeclaration-parentRule">parentRule</a>;
23332335
attribute DOMString <a href="#dom-cssstyledeclaration-cssfloat" title="dom-CSSStyleDeclaration-cssFloat">cssFloat</a>;<!-- setProperty's value arg has [TreatNullAs=EmptyString] -->
@@ -2411,35 +2413,97 @@ <h4 id="the-cssstyledeclaration-interface"><span class="secno">6.6.1 </span>The
24112413
algorithm.</li>
24122414
<li><p>If <var>value</var> is the empty string, invoke <code title="dom-CSSStyleDeclaration-removeProperty"><a href="#dom-cssstyledeclaration-removeproperty">removeProperty()</a></code>
24132415
with <var>property</var> as argument and terminate this algorithm.</li>
2414-
<li><p>If <var>priority</var> is not specified, let <var>priority action</var> be "leave as is". Otherwise, if <var>priority</var> is the empty string, let
2415-
<var>priority action</var> be "unset important". Otherwise, if <var>priority</var> is an <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> match for the
2416-
string "<code title="">important</code>", set <var>priority action</var> to "set important". Otherwise, terminate this algorithm.
2416+
<li><p>If <var>priority</var> is not the empty string and is not an <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> match for the string
2417+
"<code title="">important</code>", terminate this algorithm.
24172418
<li>
24182419
<p>Let <var>component value list</var> be the result of <a href="#parse-a-css-value" title="parse a CSS value">parsing</a> <var>value</var>.
24192420
<p class="note"><var>value</var> can not include "<code title="">!important</code>".</p>
24202421
</li>
24212422
<li><p>If <var>component value list</var> is null terminate these steps.
24222423
<li><p>If <var>property</var> is a shorthand property, then for each longhand property <var>longhand</var> that <var>property</var> maps to, in canonical
2423-
order, <a href="#set-a-css-property" title="set a CSS property">set the CSS property</a> <var>longhand</var> to the appropriate value(s) from <var>component value list</var>, with
2424-
<i>priority action</i> being <var>priority action</var>, and with the list of declarations being the
2424+
order, <a href="#append-a-css-declaration" title="append a CSS declaration">append the CSS declaration</a> <var>longhand</var> with the appropriate value(s) from <var>component value
2425+
list</var>, with the <i>important</i> flag set if <var>priority</var> is not the empty string, and unset otherwise, and with the list of declarations being the
24252426
<a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a>.
2426-
<li><p>Otherwise, <a href="#set-a-css-property" title="set a CSS property">set the CSS property</a> <var>property</var> to <var>component value list</var>, with
2427-
<i>priority action</i> being <var>priority action</var>, and with the list of declarations being the
2427+
<li><p>Otherwise, <a href="#append-a-css-declaration" title="append a CSS declaration">append the CSS declaration</a> <var>property</var> with value <var>component value list</var>, with
2428+
the <i>important</i> flag set if <var>priority</var> is not the empty string, and unset otherwise, and with the list of declarations being the
24282429
<a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a>.
24292430
</ol>
24302431

2431-
<p>To <dfn id="set-a-css-property">set a CSS property</dfn> <var>property</var> to a value <var>component value list</var> and with <i>priority action</i> being either "set
2432-
important", "unset important" or "leave as is", in a list of declarations <var>declarations</var>, follow these steps:
2432+
<p>To <dfn id="append-a-css-declaration">append a CSS declaration</dfn> <var>property</var> with a value <var>component value list</var> and optionally with an <i>important</i> flag set, in
2433+
a list of declarations <var>declarations</var>, follow these steps:
24332434

24342435
<ol>
24352436
<li><p>If <var>property</var> is a <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#case-sensitive">case-sensitive</a> match for a <a href="#concept-css-declaration-property-name" title="concept-css-declaration-property-name">property
24362437
name</a> of a <a href="#css-declaration">CSS declaration</a> in <var>declarations</var>, let <var>declaration</var> be that <a href="#css-declaration">CSS declaration</a>.
24372438
<li><p>Otherwise, append a new <a href="#css-declaration">CSS declaration</a> with the <a href="#concept-css-declaration-property-name" title="concept-css-declaration-property-name">property name</a> <var>property</var>
24382439
to <var>declarations</var> and let <var>declaration</var> be that <a href="#css-declaration">CSS declaration</a>.
2440+
<li><p>If <var>declaration</var> has its <a href="#concept-css-declaration-important-flag" title="concept-css-declaration-important-flag">important flag</a> set and the <i>important</i> flag is not set,
2441+
terminate these steps.
24392442
<li><p>Set <var>declaration</var>'s <a href="#concept-css-declaration-value" title="concept-css-declaration-value">value</a> to <var>component value list</var>.
2440-
<li><p>If <i>priority action</i> is "set important", set <var>declaration</var>'s <a href="#concept-css-declaration-important-flag" title="concept-css-declaration-important-flag">important flag</a>.
2441-
<li><p>Otherwise, if <i>priority action</i> is "unset important", unset <var>declaration</var>'s <a href="#concept-css-declaration-important-flag" title="concept-css-declaration-important-flag">important
2442-
flag</a>.
2443+
<li><p>If the <i>important</i> flag is set, set <var>declaration</var>'s <a href="#concept-css-declaration-important-flag" title="concept-css-declaration-important-flag">important flag</a>.
2444+
</ol>
2445+
2446+
<p>The <dfn id="dom-cssstyledeclaration-setpropertyvalue" title="dom-CSSStyleDeclaration-setPropertyValue"><code>setPropertyValue(<var>property</var>, <var>value</var>)</code></dfn> method must run these
2447+
steps:</p>
2448+
<ol>
2449+
<li><p>If the <a href="#concept-css-declaration-block-readonly-flag" title="concept-css-declaration-block-readonly-flag">readonly flag</a> is set, <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a>
2450+
a <code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#nomodificationallowederror">NoModificationAllowedError</a></code> exception and terminate these steps.</li>
2451+
<li><p>Let <var>property</var> be <var>property</var> <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#converted-to-ascii-lowercase">converted to ASCII lowercase</a>.
2452+
<li><p>If <var>property</var> is not a <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#case-sensitive">case-sensitive</a> match for a <a href="#supported-css-property">supported CSS property</a>, terminate this
2453+
algorithm.</li>
2454+
<li><p>If <var>value</var> is the empty string, invoke <code title="dom-CSSStyleDeclaration-removeProperty"><a href="#dom-cssstyledeclaration-removeproperty">removeProperty()</a></code>
2455+
with <var>property</var> as argument and terminate this algorithm.</li>
2456+
<li>
2457+
<p>Let <var>component value list</var> be the result of <a href="#parse-a-css-value" title="parse a CSS value">parsing</a> <var>value</var>.
2458+
<p class="note"><var>value</var> can not include "<code title="">!important</code>".</p>
2459+
</li>
2460+
<li><p>If <var>component value list</var> is null terminate these steps.
2461+
<li><p>If <var>property</var> is a shorthand property, then for each longhand property <var>longhand</var> that <var>property</var> maps to, in canonical
2462+
order, <a href="#set-a-css-declaration-value" title="set a CSS declaration value">set the CSS declaration value</a> <var>longhand</var> to the appropriate value(s) from <var>component
2463+
value list</var>, and with the list of declarations being the <a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a>.
2464+
<li><p>Otherwise, <a href="#set-a-css-declaration-value" title="set a CSS declaration value">set the CSS declaration value</a> <var>property</var> to the value <var>component value
2465+
list</var>, and with the list of declarations being the <a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a>.
2466+
</ol>
2467+
2468+
<p>To <dfn id="set-a-css-declaration-value">set a CSS declaration value</dfn> to a value <var>component value list</var> in a list of declarations <var>declarations</var>, follow these steps:
2469+
2470+
<ol>
2471+
<li><p>If <var>property</var> is a <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#case-sensitive">case-sensitive</a> match for a <a href="#concept-css-declaration-property-name" title="concept-css-declaration-property-name">property
2472+
name</a> of a <a href="#css-declaration">CSS declaration</a> in <var>declarations</var>, let <var>declaration</var> be that <a href="#css-declaration">CSS declaration</a>.
2473+
<li><p>Otherwise, append a new <a href="#css-declaration">CSS declaration</a> with the <a href="#concept-css-declaration-property-name" title="concept-css-declaration-property-name">property name</a> <var>property</var>
2474+
to <var>declarations</var> and let <var>declaration</var> be that <a href="#css-declaration">CSS declaration</a>.
2475+
<li><p>Set <var>declaration</var>'s <a href="#concept-css-declaration-value" title="concept-css-declaration-value">value</a> to <var>component value list</var>.
2476+
</ol>
2477+
2478+
<p>The <dfn id="dom-cssstyledeclaration-setpropertypriority" title="dom-CSSStyleDeclaration-setPropertyPriority"><code>setPropertyPriority(<var>property</var>, <var>priority</var>)</code></dfn> method must run
2479+
these steps:</p>
2480+
2481+
<ol>
2482+
<li><p>If the <a href="#concept-css-declaration-block-readonly-flag" title="concept-css-declaration-block-readonly-flag">readonly flag</a> is set, <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a>
2483+
a <code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#nomodificationallowederror">NoModificationAllowedError</a></code> exception and terminate these steps.</li>
2484+
<li><p>Let <var>property</var> be <var>property</var> <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#converted-to-ascii-lowercase">converted to ASCII lowercase</a>.
2485+
<li><p>If <var>property</var> is not a <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#case-sensitive">case-sensitive</a> match for a <a href="#supported-css-property">supported CSS property</a>, terminate this
2486+
algorithm.</li>
2487+
<li><p>If <var>priority</var> is not the empty string and is not an <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> match for the string
2488+
"<code title="">important</code>", terminate this algorithm.
2489+
<li><p>If <var>property</var> is a shorthand property, then for each longhand property <var>longhand</var> that <var>property</var> maps to, in canonical
2490+
order, <a href="#set-a-css-declaration-priority" title="set a CSS declaration priority">set the CSS declaration priority</a> <var>longhand</var> with the <i>important</i> flag set if
2491+
<var>priority</var> is not the empty string, and unset otherwise, and with the list of declarations being the
2492+
<a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a>.
2493+
<li><p>Otherwise, <a href="#set-a-css-declaration-priority" title="set a CSS declaration priority">set the CSS declaration priority</a> <var>property</var> with the <i>important</i> flag set
2494+
if <var>priority</var> is not the empty string, and unset otherwise, and with the list of declarations being the
2495+
<a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a>.
2496+
</ol>
2497+
2498+
<p>To <dfn id="set-a-css-declaration-priority">set a CSS declaration priority</dfn> <var>property</var> optionally with an <i>important</i> flag set, in a list of declarations
2499+
<var>declarations</var>, follow these steps:
2500+
2501+
<ol>
2502+
<li><p>If <var>property</var> is a <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#case-sensitive">case-sensitive</a> match for a <a href="#concept-css-declaration-property-name" title="concept-css-declaration-property-name">property
2503+
name</a> of a <a href="#css-declaration">CSS declaration</a> in <var>declarations</var>, let <var>declaration</var> be that <a href="#css-declaration">CSS declaration</a>.
2504+
<li><p>Otherwise, terminate these steps.
2505+
<li><p>If the <i>important</i> flag is set, set <var>declaration</var>'s <a href="#concept-css-declaration-important-flag" title="concept-css-declaration-important-flag">important flag</a>. Otherwise,
2506+
unset <var>declaration</var>'s <a href="#concept-css-declaration-important-flag" title="concept-css-declaration-important-flag">important flag</a>.
24432507
</ol>
24442508

24452509
<p>The <dfn id="dom-cssstyledeclaration-removeproperty" title="dom-CSSStyleDeclaration-removeProperty"><code>removeProperty(<var>property</var>)</code></dfn> method must run these steps:</p>

0 commit comments

Comments
 (0)