Serializing: Descendants of (R)CDATA elements

The serializing of HTML fragments algorithm currently looks up the  
ancestor chain for Text and CDATASection nodes for CDATA elements (or  
<plaintext>) in order to decide when to escape text.

Firefox takes a different approach, it seems: when finding an (R)CDATA  
element (or <plaintext>), emit the data of the child Text and CDATASection  
nodes (escaped or not as appropriate) instead of recursing the algorithm  
on its subtree.

I think Firefox's approach is a bit more performant (it would probably be  
less checking in the general case), and it roundtrips a bit better; as the  
spec notes:

    For instance, if a textarea element to which a Comment node has been
    appended is serialised and the output is then reparsed, the comment
    will end up being displayed in the text field.

Simon Pieters
Opera Software

Received on Tuesday, 18 March 2008 20:22:02 UTC