Re: Beginning of a spec on style batching/flushing?

On 12/10/13 11:27 PM, Tab Atkins Jr. wrote:
>    Each element in a document is associated with a <dfn export>style
> updates queue</dfn>

This explicitly orders the style updates, but...

>    A <dfn>style update</dfn> is a pending currently-unapplied change
> made to the style of an element on the page
>    which might have an effect on the style, layout, or rendering of the element.

I'm not sure what that means.  Consider this testcase:

<style>
   .highlighted { color: purple; }
   .also { background: green; }
</style>
<div>Some text</div>
<script>
   var div = document.querySelector("div");
   div.offsetWidth; // Flush styles on div.... more on this below
   div.className = "highlighted";
   // What's in the style updates queue for the div now?
   div.className = "also";
   // And now?
   div.className = "also highlighted";
   // What about now?
</script>

The other thing I'd like to understand is whether we can have a 
situation like so for style updates queues:

Element A: Update 1, Action 2, Update 3
Element B: Update 4, Action 5, Update 6

where Update 3 and Update 4 were triggered by the same DOM mutation. 
Seems like this should be possible, right?  So in this situation we need 
to apply Update 1 (but not any of the other updates, so basically style 
the DOM as if the mutation that caused Update 3 has not happened yet?), 
then do Action 2, then do the rest of the stuff in any order as long as 
update 4 precedes action 5 which precedes update 6?

Or am I totally misunderstanding the proposal?

>    User agents should prioritize applying <a>style updates</a>
>    that precede a <a>style-dependent action</a>
>    when a <a>style-dependent action</a> is in the queue.

Prioritize over what?

-Boris

Received on Wednesday, 11 December 2013 05:07:12 UTC