[whatwg] No-DOM HTML

Michel Fortin michel.fortin at michelf.com
Sat Jun 2 05:35:41 PDT 2007


Le 2007-06-02 à 4:39, Anne van Kesteren a écrit :

> On Wed, 30 May 2007 15:22:39 +0200, Michel Fortin  
> <michel.fortin at michelf.com> wrote:
>> 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.
>
> This is not an option. Consider
>
>   <b><p>test</p></b>
>
> versus
>
>   <b><p>test</b>
>
> Sending mutation events is probably the only way to go.

I'm not sure I follow; what is the problem here? My suggestion was  
for the parser to keep a temporary tree whenever things are likely to  
be subject to reordering (like this case). If needed the parser just  
mutates its internal temporary tree. When a part of that tree are  
guarantied not to need reordered, then it can send SAX events for  
that part. The idea is effectively to *avoid* mutate events from  
going outside the parser since the application at the other ends, or  
the API in between, doesn't support them.

Note that this doesn't work for parsing full documents since you  
can't append to the root attributes found in misplaced <html> tags  
while not keeping a tree of the whole document. But this could prove  
very useful for parsing HTML snippets to be included in a document  
server-side, just like you can do with innerHTML in the DOM.


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





More information about the whatwg mailing list