Skip to content

Commit 03cef6e

Browse files
committed
[cssom-1] Add updating flag to CSS declaration block to avoid serialize-and-reparse on style attribute.
1 parent 71f88df commit 03cef6e

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

cssom-1/Overview.bs

Lines changed: 22 additions & 11 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:
@@ -2038,6 +2042,7 @@ A <a>CSS declaration block</a> has these <a>attribute change steps</a> for its <
20382042

20392043
<ol>
20402044
<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.
20412046
<li>If <var>localName</var> is not "<code>style</code>", or <var>namespace</var> is not null, terminate these steps.
20422047
<li>If <var>value</var> is null, empty the <a for="CSSStyleDeclaration">declarations</a>.
20432048
<li>Otherwise, let the <a for="CSSStyleDeclaration">declarations</a> be the result of <a>parse a CSS declaration block</a>
@@ -2055,6 +2060,18 @@ When a <a>CSS declaration block</a> object is created, then:
20552060
<a>parse a CSS declaration block</a> from a string <var>value</var>.
20562061
</ol>
20572062

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+
20582075
The <dfn id=concept-shorthands-preferred-order>preferred order</dfn> of a list of shorthand properties <var>shorthands</var> is as follows:
20592076

20602077
<ol>
@@ -2100,8 +2117,7 @@ Setting the {{CSSStyleDeclaration/cssText}} attribute must run these steps:
21002117
<li>Empty the <a for="CSSStyleDeclaration">declarations</a>.
21012118
<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
21022119
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>.
2120+
<li><a>Update style attribute for</a> the <a>CSS declaration block</a>.
21052121
</ol>
21062122

21072123
The <dfn attribute for=CSSStyleDeclaration>length</dfn> attribute must return the number of <a lt="CSS declaration">CSS
@@ -2187,8 +2203,7 @@ The <dfn method for=CSSStyleDeclaration>setProperty(<var>property</var>, <var>va
21872203
<li>Otherwise, <a lt="set a CSS declaration">set the CSS declaration</a> <var>property</var> with value <var>component value list</var>, with
21882204
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
21892205
<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>.
2206+
<li><a>Update style attribute for</a> the <a>CSS declaration block</a>.
21922207
</ol>
21932208

21942209
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
@@ -2227,8 +2242,7 @@ steps:
22272242
value list</var>, and with the list of declarations being the <a for="CSSStyleDeclaration">declarations</a>.
22282243
<li>Otherwise, <a lt="set a CSS declaration value">set the CSS declaration value</a> <var>property</var> to the value <var>component value
22292244
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>.
2245+
<li><a>Update style attribute for</a> the <a>CSS declaration block</a>.
22322246
</ol>
22332247

22342248
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:
@@ -2261,8 +2275,7 @@ these steps:
22612275
<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
22622276
if <var>priority</var> is not the empty string, and unset otherwise, and with the list of declarations being the
22632277
<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>.
2278+
<li><a>Update style attribute for</a> the <a>CSS declaration block</a>.
22662279
</ol>
22672280

22682281
To <dfn>set a CSS declaration priority</dfn> <var>property</var> optionally with an <i>important</i> flag set, in a list of declarations
@@ -2294,9 +2307,7 @@ The <dfn method for=CSSStyleDeclaration>removeProperty(<var>property</var>)</dfn
22942307
<li>Otherwise, if <var>property</var> is a <a>case-sensitive</a> match for a
22952308
<a for="CSS declaration">property name</a> of a <a>CSS declaration</a> in the
22962309
<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>.
2310+
<li>If <var>removed</var> is true, <a>Update style attribute for</a> the <a>CSS declaration block</a>.
23002311
<li>Return <var>value</var>.
23012312
</ol>
23022313

0 commit comments

Comments
 (0)