W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2007

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

From: Michel Fortin <michel.fortin@michelf.com>
Date: Wed, 30 May 2007 09:22:39 -0400
Message-ID: <E89E341C-DD11-49CF-AA7D-4ABEE9E0FD38@michelf.com>
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
Received on Wednesday, 30 May 2007 06:22:39 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:55 UTC