W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2009

[whatwg] Serializing HTML fragments (9.4)

From: Kartikaya Gupta <lists.whatwg@stakface.com>
Date: Thu, 09 Jul 2009 14:09:27 +0000
Message-ID: <20090709140927.DFB958DB001D@zapata.dreamhost.com>
According to this section 9.4, any descendant text node of a style element should be outputted literally, rather than being escaped. However, this doesn't seem to match what Opera/Chrome/FF do. Test case:

  <style id="test">  
  <script type="text/javascript"> 
    var test = document.getElementById("test");
    var c1 = document.createElement( 'c1' );
    c1.appendChild( document.createTextNode( 'some>stuff' ) );
    test.appendChild( c1 );
    test.appendChild( document.createTextNode( 'more<stuff' ) );
    var html = test.innerHTML;

Opera and Chrome will alert "<c1>some&gt;stuff</c1>more<stuff" (escaping the angle bracket inside the child element) and Firefox just outputs "more<stuff" (presumably a bug). I tried a couple of the other special elements (script and xmp) and they worked the same way. I think for compatibility the spec should say "If the parent of the current node is a" instead of "If one of the ancestors of current node is a" for the Text/CDATASection handling.

Received on Thursday, 9 July 2009 07:09:27 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:14 UTC