You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[cssom-1] Ensure inline style and corresponding declaration block updates each other properly.
This mostly follows how `DOMTokenList` works in the DOM spec, which has
a similar situation that having a live object reflecting an attribute.
This should fix#1559.
Copy file name to clipboardExpand all lines: cssom-1/Overview.bs
+43-21Lines changed: 43 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -2034,6 +2034,27 @@ Note: The serialization of an empty CSS declaration block is the empty string.
2034
2034
Note: The serialization of a non-empty CSS declaration block does not include any surrounding whitespace, i.e., no whitespace appears
2035
2035
before the first property name and no whitespace appears after the final semicolon delimiter that follows the last property value.
2036
2036
2037
+
A <a>CSS declaration block</a> has these <a>attribute change steps</a> for its <a for="CSSStyleDeclaration">owner node</a>:
2038
+
2039
+
<ol>
2040
+
<li>If the <a for="CSSStyleDeclaration">readonly flag</a> is set, terminate these steps.
2041
+
<li>If <var>localName</var> is not "<code>style</code>", or <var>namespace</var> is not null, terminate these steps.
2042
+
<li>If <var>value</var> is null, empty the <a for="CSSStyleDeclaration">declarations</a>.
2043
+
<li>Otherwise, let the <a for="CSSStyleDeclaration">declarations</a> be the result of <a>parse a CSS declaration block</a>
2044
+
from a string <var>value</var>.
2045
+
</ol>
2046
+
2047
+
When a <a>CSS declaration block</a> object is created, then:
2048
+
2049
+
<ol>
2050
+
<li>Let <var>owner node</var> be the <a for="CSSStyleDeclaration">owner node</a>.
2051
+
<li>If <var>owner node</var> is null, or the <a for="CSSStyleDeclaration">readonly flag</a> is set, terminate these steps.
2052
+
<li>Let <var>value</var> be the result of <a lt="get an attribute by namespace and local name">getting an attribute</a>
2053
+
given null, "<code>style</code>", and <var>owner node</var>.
2054
+
<li>If <var>value</var> is not null, let the <a for="CSSStyleDeclaration">declarations</a> be the result of
2055
+
<a>parse a CSS declaration block</a> from a string <var>value</var>.
2056
+
</ol>
2057
+
2037
2058
The <dfn id=concept-shorthands-preferred-order>preferred order</dfn> of a list of shorthand properties <var>shorthands</var> is as follows:
2038
2059
2039
2060
<ol>
@@ -2079,6 +2100,8 @@ Setting the {{CSSStyleDeclaration/cssText}} attribute must run these steps:
2079
2100
<li>Empty the <a for="CSSStyleDeclaration">declarations</a>.
2080
2101
<li><a lt="Parse a CSS declaration block">Parse</a> the given value and, if the return value is not the empty list, insert the items in the list
2081
2102
into the <a for="CSSStyleDeclaration">declarations</a>, in <a>specified order</a>.
2103
+
<li>If the <a for="CSSStyleDeclaration">owner node</a> is not null, <a>set an attribute value</a> for <a for="CSSStyleDeclaration">owner node</a>
2104
+
using "<code>style</code>" and the result of <a lt="serialize a CSS declaration block">serializing</a> the <a for="CSSStyleDeclaration">declarations</a>.
2082
2105
</ol>
2083
2106
2084
2107
The <dfn attribute for=CSSStyleDeclaration>length</dfn> attribute must return the number of <a lt="CSS declaration">CSS
@@ -2164,6 +2187,8 @@ The <dfn method for=CSSStyleDeclaration>setProperty(<var>property</var>, <var>va
2164
2187
<li>Otherwise, <a lt="set a CSS declaration">set the CSS declaration</a><var>property</var> with value <var>component value list</var>, with
2165
2188
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
2166
2189
<a for="CSSStyleDeclaration">declarations</a>.
2190
+
<li>If the <a for="CSSStyleDeclaration">owner node</a> is not null, <a>set an attribute value</a> for <a for="CSSStyleDeclaration">owner node</a>
2191
+
using "<code>style</code>" and the result of <a lt="serialize a CSS declaration block">serializing</a> the <a for="CSSStyleDeclaration">declarations</a>.
2167
2192
</ol>
2168
2193
2169
2194
To <dfn>set 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
@@ -2202,6 +2227,8 @@ steps:
2202
2227
value list</var>, and with the list of declarations being the <a for="CSSStyleDeclaration">declarations</a>.
2203
2228
<li>Otherwise, <a lt="set a CSS declaration value">set the CSS declaration value</a><var>property</var> to the value <var>component value
2204
2229
list</var>, and with the list of declarations being the <a for="CSSStyleDeclaration">declarations</a>.
2230
+
<li>If the <a for="CSSStyleDeclaration">owner node</a> is not null, <a>set an attribute value</a> for <a for="CSSStyleDeclaration">owner node</a>
2231
+
using "<code>style</code>" and the result of <a lt="serialize a CSS declaration block">serializing</a> the <a for="CSSStyleDeclaration">declarations</a>.
2205
2232
</ol>
2206
2233
2207
2234
To <dfn>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:
@@ -2234,6 +2261,8 @@ these steps:
2234
2261
<li>Otherwise, <a lt="set a CSS declaration priority">set the CSS declaration priority</a><var>property</var> with the <i>important</i> flag set
2235
2262
if <var>priority</var> is not the empty string, and unset otherwise, and with the list of declarations being the
2236
2263
<a for="CSSStyleDeclaration">declarations</a>.
2264
+
<li>If the <a for="CSSStyleDeclaration">owner node</a> is not null, <a>set an attribute value</a> for <a for="CSSStyleDeclaration">owner node</a>
2265
+
using "<code>style</code>" and the result of <a lt="serialize a CSS declaration block">serializing</a> the <a for="CSSStyleDeclaration">declarations</a>.
2237
2266
</ol>
2238
2267
2239
2268
To <dfn>set a CSS declaration priority</dfn><var>property</var> optionally with an <i>important</i> flag set, in a list of declarations
@@ -2255,11 +2284,19 @@ The <dfn method for=CSSStyleDeclaration>removeProperty(<var>property</var>)</dfn
2255
2284
let <var>property</var> be <var>property</var><a lt="ASCII lowercase">converted to ASCII lowercase</a>.
2256
2285
<li>Let <var>value</var> be the return value of invoking {{CSSStyleDeclaration/getPropertyValue()}}
2257
2286
with <var>property</var> as argument.
2258
-
<li>If <var>property</var> is a shorthand property, for each longhand property <var>longhand</var> that <var>property</var> maps to, invoke
2259
-
{{CSSStyleDeclaration/removeProperty()}} with <var>longhand</var> as argument.
2287
+
<li>Let <var>removed</var> be false.
2288
+
<li>If <var>property</var> is a shorthand property, for each longhand property <var>longhand</var> that <var>property</var> maps to:
2289
+
<ol>
2290
+
<li>If <var>longhand</var> is not a <a for="CSS declaration">property name</a> of a <a>CSS declaration</a>
2291
+
in the <a for="CSSStyleDeclaration">declarations</a>, <a for=iteration>continue</a>.
2292
+
<li>Remove that <a>CSS declaration</a> and let <var>removed</var> be true.
2293
+
</ol>
2260
2294
<li>Otherwise, if <var>property</var> is a <a>case-sensitive</a> match for a
2261
2295
<a for="CSS declaration">property name</a> of a <a>CSS declaration</a> in the
2262
-
<a for="CSSStyleDeclaration">declarations</a>, remove that <a>CSS declaration</a>.
2296
+
<a for="CSSStyleDeclaration">declarations</a>, remove that <a>CSS declaration</a> and let <var>removed</var> be true.
2297
+
<li>If <var>removed</var> is true and <a for="CSSStyleDeclaration">owner node</a> is not null, <a>set an attribute value</a>
2298
+
for <a for="CSSStyleDeclaration">owner node</a> using "<code>style</code>" and the result of
2299
+
<a lt="serialize a CSS declaration block">serializing</a> the <a for="CSSStyleDeclaration">declarations</a>.
0 commit comments