This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Suggestion for the "text insertion mode" of HTML parser: add 'An end tag whose tag name is "style"' rule similar to the "script" one, to notify "style" elements that their contents is ready to be processed. Otherwise, there is no way for the HTMLStyleElement to find out when to start parsing embedded stylesheet rules.
The style element _always_ applies its contents. So there's no need to tell it to start doing so.
Okay. Just wanted to point out that it is not obvious from the specs __when_exactly__ style element should apply its contents. The parser algorithm is built in such a way, that the style element doesn't know it's contents has changed. Specifically, after the style tag is opened, the parser inserts an empty text node into the style element (and obviously content cannot be applied at this point, because it is empty), and then only starts appending characters to the text node. The style element has no way of knowing that the parser has __finished__ inserting characters so that the contents can be applied.
It doesn't need to know when it's finished. It should start applying the style rules when it's empty ("" is a valid CSS style sheet), and then each time a character is added, it should reparse the style sheet and apply it. This is covered by this statement: # For styling languages that consist of pure text (as opposed to XML), user # agents must evaluate style elements by passing the concatenation of the # contents of all the Text nodes that are children of the style element # (not any other nodes such as comments or elements), in tree order, to the # style system. (This text is likely to be clarified as part of bug 14703.)
hmm... suppose the contents of the style element is made up of 10 000 characters representing a CSS stylesheet. The parser appends characters one by one. So the style sheet has to be parsed 10 000 times? Doesn't it look a little inefficient? It is understandable that _after_ the document has been parsed, any modification to the contents of the style element must be applied (i.e. the stylesheet has to be re-parsed). But why do we need to apply every inserted character during the initial parsing? Would it not be better to populate the contents of the style element, and apply it _after_ the style tag is closed? I want to emphasize, that the above said applies _only_ to the initial HTML parsing algorithm. When/if the contents of the style element is altered by a script, it must be applied and re-parsed immediately, by all means and no doubt.
So long as the result is indistinguishable, the browser can implement this as efficiently as it wants. In practice, the browser will probably wait until the next time it renders the document before even looking at the <style> element. There's no difference between when the document is parsed and when it's dynamically modified, as far as this goes. At least, that's the theory.
I see your point. So in practice, we will just set "dirty" flag on the style element whenever its contents is changed, and re-process the stylesheet whenever the browser needs to access any style-dependent data. I guess that was your initial intention in the phrase # For styling languages that consist of pure text (as opposed to XML), user # agents must evaluate style elements by passing the concatenation of the # contents of all the Text nodes that are children of the style element # (not any other nodes such as comments or elements), in tree order, to the # style system. I just failed to understand it correctly.
Yeah the text is poorly written. I hope to improve it as part of bug 14703.