Skip to content

Commit 79619b8

Browse files
authored
Merge pull request #2269 from upsuper/cssom-style-attr
[cssom-1] Ensure inline style and corresponding declaration block ates each other properly
2 parents a6e3e69 + 03cef6e commit 79619b8

File tree

1 file changed

+54
-21
lines changed

1 file changed

+54
-21
lines changed

cssom-1/Overview.bs

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,10 @@ the DOM a <a>CSS declaration block</a> is a
19521952
<dt><dfn>owner node</dfn>
19531953
<dd>The {{Element}} that the <a>CSS declaration block</a> is associated with, if any, or
19541954
null otherwise.
1955+
1956+
<dt><dfn>updating flag</dfn>
1957+
<dd>Unset by default. Set when the <a>CSS declaration block</a> is updating
1958+
the <a for="CSSStyleDeclaration">owner node</a>'s <code>style</code> attribute.
19551959
</dl>
19561960

19571961
To <dfn>parse a CSS declaration block</dfn> from a string <var>string</var>, follow these steps:
@@ -2034,6 +2038,40 @@ Note: The serialization of an empty CSS declaration block is the empty string.
20342038
Note: The serialization of a non-empty CSS declaration block does not include any surrounding whitespace, i.e., no whitespace appears
20352039
before the first property name and no whitespace appears after the final semicolon delimiter that follows the last property value.
20362040

2041+
A <a>CSS declaration block</a> has these <a>attribute change steps</a> for its <a for="CSSStyleDeclaration">owner node</a>:
2042+
2043+
<ol>
2044+
<li>If the <a for="CSSStyleDeclaration">readonly flag</a> is set, terminate these steps.
2045+
<li>If the <a for="CSSStyleDeclaration">updating flag</a> is set, terminate these steps.
2046+
<li>If <var>localName</var> is not "<code>style</code>", or <var>namespace</var> is not null, terminate these steps.
2047+
<li>If <var>value</var> is null, empty the <a for="CSSStyleDeclaration">declarations</a>.
2048+
<li>Otherwise, let the <a for="CSSStyleDeclaration">declarations</a> be the result of <a>parse a CSS declaration block</a>
2049+
from a string <var>value</var>.
2050+
</ol>
2051+
2052+
When a <a>CSS declaration block</a> object is created, then:
2053+
2054+
<ol>
2055+
<li>Let <var>owner node</var> be the <a for="CSSStyleDeclaration">owner node</a>.
2056+
<li>If <var>owner node</var> is null, or the <a for="CSSStyleDeclaration">readonly flag</a> is set, terminate these steps.
2057+
<li>Let <var>value</var> be the result of <a lt="get an attribute by namespace and local name">getting an attribute</a>
2058+
given null, "<code>style</code>", and <var>owner node</var>.
2059+
<li>If <var>value</var> is not null, let the <a for="CSSStyleDeclaration">declarations</a> be the result of
2060+
<a>parse a CSS declaration block</a> from a string <var>value</var>.
2061+
</ol>
2062+
2063+
To <dfn>update style attribute for</dfn> <var>declaration block</var> means to run the steps below:
2064+
2065+
<ol>
2066+
<li>Assert: <var>declaration block</var>'s <a for="CSSStyleDeclaration">readonly flag</a> is unset.
2067+
<li>Let <var>owner node</var> be <var>declaration block</var>'s <a for="CSSStyleDeclaration">owner node</a>.
2068+
<li>If <var>owner node</var> is null, terminate these steps.
2069+
<li>Set <var>declaration block</var>'s <a for="CSSStyleDeclaration">updating flag</a>.
2070+
<li><a>Set an attribute value</a> for <var>owner node</var> using "<code>style</code>" and the result of
2071+
<a lt="serialize a CSS declaration block">serializing</a> <var>declaration block</var>.
2072+
<li>Unset <var>declaration block</var>'s <a for="CSSStyleDeclaration">updating flag</a>.
2073+
</ol>
2074+
20372075
The <dfn id=concept-shorthands-preferred-order>preferred order</dfn> of a list of shorthand properties <var>shorthands</var> is as follows:
20382076

20392077
<ol>
@@ -2079,6 +2117,7 @@ Setting the {{CSSStyleDeclaration/cssText}} attribute must run these steps:
20792117
<li>Empty the <a for="CSSStyleDeclaration">declarations</a>.
20802118
<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
20812119
into the <a for="CSSStyleDeclaration">declarations</a>, in <a>specified order</a>.
2120+
<li><a>Update style attribute for</a> the <a>CSS declaration block</a>.
20822121
</ol>
20832122

20842123
The <dfn attribute for=CSSStyleDeclaration>length</dfn> attribute must return the number of <a lt="CSS declaration">CSS
@@ -2164,6 +2203,7 @@ The <dfn method for=CSSStyleDeclaration>setProperty(<var>property</var>, <var>va
21642203
<li>Otherwise, <a lt="set a CSS declaration">set the CSS declaration</a> <var>property</var> with value <var>component value list</var>, with
21652204
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
21662205
<a for="CSSStyleDeclaration">declarations</a>.
2206+
<li><a>Update style attribute for</a> the <a>CSS declaration block</a>.
21672207
</ol>
21682208

21692209
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 +2242,7 @@ steps:
22022242
value list</var>, and with the list of declarations being the <a for="CSSStyleDeclaration">declarations</a>.
22032243
<li>Otherwise, <a lt="set a CSS declaration value">set the CSS declaration value</a> <var>property</var> to the value <var>component value
22042244
list</var>, and with the list of declarations being the <a for="CSSStyleDeclaration">declarations</a>.
2245+
<li><a>Update style attribute for</a> the <a>CSS declaration block</a>.
22052246
</ol>
22062247

22072248
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 +2275,7 @@ these steps:
22342275
<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
22352276
if <var>priority</var> is not the empty string, and unset otherwise, and with the list of declarations being the
22362277
<a for="CSSStyleDeclaration">declarations</a>.
2278+
<li><a>Update style attribute for</a> the <a>CSS declaration block</a>.
22372279
</ol>
22382280

22392281
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 +2297,17 @@ The <dfn method for=CSSStyleDeclaration>removeProperty(<var>property</var>)</dfn
22552297
let <var>property</var> be <var>property</var> <a lt="ASCII lowercase">converted to ASCII lowercase</a>.
22562298
<li>Let <var>value</var> be the return value of invoking {{CSSStyleDeclaration/getPropertyValue()}}
22572299
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.
2300+
<li>Let <var>removed</var> be false.
2301+
<li>If <var>property</var> is a shorthand property, for each longhand property <var>longhand</var> that <var>property</var> maps to:
2302+
<ol>
2303+
<li>If <var>longhand</var> is not a <a for="CSS declaration">property name</a> of a <a>CSS declaration</a>
2304+
in the <a for="CSSStyleDeclaration">declarations</a>, <a for=iteration>continue</a>.
2305+
<li>Remove that <a>CSS declaration</a> and let <var>removed</var> be true.
2306+
</ol>
22602307
<li>Otherwise, if <var>property</var> is a <a>case-sensitive</a> match for a
22612308
<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>.
2309+
<a for="CSSStyleDeclaration">declarations</a>, remove that <a>CSS declaration</a> and let <var>removed</var> be true.
2310+
<li>If <var>removed</var> is true, <a>Update style attribute for</a> the <a>CSS declaration block</a>.
22632311
<li>Return <var>value</var>.
22642312
</ol>
22652313

@@ -2678,24 +2726,9 @@ interface ElementCSSInlineStyle {
26782726
};
26792727
</pre>
26802728

2681-
The <dfn attribute for=ElementCSSInlineStyle>style</dfn> attribute must return a live <a>CSS declaration block</a> with the following
2682-
properties:
2683-
<dl>
2684-
<dt><a for="CSSStyleDeclaration">readonly flag</a>
2685-
<dd>Unset.
2686-
<dt><a for="CSSStyleDeclaration">declarations</a>
2687-
<dd>The result of <a lt="Parse a CSS declaration block">parsing</a> the <code>style</code> content attribute, in
2688-
<a>specified order</a>. If the <code>style</code> content attribute is absent, the object represents an
2689-
empty list of <a>CSS declarations</a>. Mutating the <a for="CSSStyleDeclaration">declarations</a>
2690-
must set the <code>style</code> content attribute on the <a>context object</a> to the
2691-
<a lt="serialize a CSS declaration block">serialization</a> of the <a for="CSSStyleDeclaration">declarations</a>. If the
2692-
<code>style</code> content attribute is set, changed or removed, the <a for="CSSStyleDeclaration">declarations</a> must be
2693-
updated as appropriate.
2694-
<dt><a for="CSSStyleDeclaration">parent CSS rule</a>
2695-
<dd>Null.
2696-
<dt><a for="CSSStyleDeclaration">owner node</a>
2697-
<dd>The <a>context object</a>.
2698-
</dl>
2729+
The <dfn attribute for=ElementCSSInlineStyle>style</dfn> attribute must return a <a>CSS declaration block</a> object whose
2730+
<a for="CSSStyleDeclaration">readonly flag</a> is unset, whose <a for="CSSStyleDeclaration">parent CSS rule</a> is null, and
2731+
whose <a for="CSSStyleDeclaration">owner node</a> is the <a>context object</a>.
26992732

27002733
If the user agent supports HTML, the following IDL applies: [[HTML]]
27012734

0 commit comments

Comments
 (0)