[whatwg] No-DOM HTML (was: <noscript> should be allowed in <head>)

Le 2007-05-30 ? 8:25, Henri Sivonen a ?crit :

> The parsing spec allows a Draconian response to parse errors.  
> Hence, if you want SAX events, you have two conforming options:
>  1) Build a tree in its entirety first and then emit the events  
> based on the tree.
>  2) Emit events as the parse progresses and halt on errors that  
> require non-streamable recovery.

Or, assuming the spec changes to no longer move head-elements (like  
<link>) to the head when they're found in body, there is a third option:

3) Emit events until you reach a point where it may be possible that  
some events should be reordered, in which case you build a local DOM- 
like tree and wait until you can emit all pending events with a  
certainty they don't need to be reordered.

For instance, <table> requires maintaining a local DOM-like tree  
until the corresponding </table> has been reached, at which point you  
know you can send events for the whole table. That's not optimal, but  
still better than keeping the whole DOM in memory and waiting until  
the end of the document to start sending events. Although it sure it  
more complicated too.

Of course, if head-elements are sent back to the head you can't go  
past the head with this technique, unless you consider yourself in  
the innerHTML case and append them to the current node, as the spec  
requires. I guess this could be fine for parsing HTML snippets  
belonging to the body for instance.


Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/

Received on Wednesday, 30 May 2007 06:22:39 UTC