W3C home > Mailing lists > Public > public-html@w3.org > March 2008

Serializing: Descendants of (R)CDATA elements

From: Simon Pieters <simonp@opera.com>
Date: Tue, 18 Mar 2008 21:21:23 +0100
To: public-html <public-html@w3.org>
Message-ID: <op.t78atxmxidj3kv@hp-a0a83fcd39d2.belkin>

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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 16:25:16 UTC