<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>27386</bug_id>
          
          <creation_ts>2014-11-21 08:48:22 +0000</creation_ts>
          <short_desc>Removing createCDATASection() unlikely to be successful</short_desc>
          <delta_ts>2017-02-02 18:19:16 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          <see_also>https://www.w3.org/Bugs/Public/show_bug.cgi?id=30058</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Philip Jägenstedt">philipj</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>crimsteam</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>VYV03354</cc>
    
    <cc>www-dom</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>115271</commentid>
    <comment_count>0</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-21 08:48:22 +0000</bug_when>
    <thetext>https://dom.spec.whatwg.org/#dom-document-createcdatasection

See usage:
https://www.chromestatus.com/metrics/feature/timeline/popularity/113

This is around 0.01%, and being a function it hurts more to remove than attributes and interfaces. Some Node-related removals failed despite lower usage.

Options:

1. Bring back CDATASection in all its glory.

2. Have createCDATASection() return a Text node.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115272</commentid>
    <comment_count>1</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2014-11-21 09:42:56 +0000</bug_when>
    <thetext>I doubt anyone would be surprised that I prefer (2).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115275</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-21 10:31:46 +0000</bug_when>
    <thetext>Philip, I think first attempting to change the result of the following demo and then deciding what we should do here is a better order:

data:text/xml,&lt;script xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;![CDATA[alert(document.currentScript.firstChild.nodeType)]]&gt;&lt;/script&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115278</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-11-21 10:47:17 +0000</bug_when>
    <thetext>If we do (2), the Text node should probably have the .serializeAsCDATA attribute set. It seems that attribute is no longer defined in DOMParsing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115279</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-21 10:57:03 +0000</bug_when>
    <thetext>There&apos;s code that relies on serialization? Can&apos;t we first figure out if just making the XML parser output Text nodes breaks anything?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115293</commentid>
    <comment_count>5</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-11-21 14:45:50 +0000</bug_when>
    <thetext>Where we can find earlier version of Parsing &amp; Serialization spec made by WHATWG? Old link automatically moves to W3C editor&apos;s draft:
http://domparsing.spec.whatwg.org/
where proposal of Text.serializeAsCDATA attribute not exist.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115294</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-21 14:50:27 +0000</bug_when>
    <thetext>https://rawgit.com/whatwg/domparsing/edc795ccfdc03e396197bf81a0f550105930e90b/source.html or https://github.com/whatwg/domparsing but it is no longer maintained.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115482</commentid>
    <comment_count>7</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-25 22:45:41 +0000</bug_when>
    <thetext>AFAICT, these are the ways that CDATASection is observable in Blink:

1. The CDATASection interface itself
2. CDATASection.nodeName is &quot;#cdata-section&quot;
3. CDATASection.nodeType is 4 (CDATA_SECTION_NODE)
4. Document.createCDATASection()
5. The XML parser can create CDATASection
6. XMLSerializer.serializeToString() can serialize CDATASection

I could add counters for 2, 3, 5 and 6 (1 is hard to count and 4 already counted) but even if the usage is high it could still be safe to remove if people are just iterating over documents and dispatching based on nodeType, for example.

Would counters for the above or anything else be worthwhile adding?

Is there a spec for XML parsing that we should have changed if we try changing the parser to output Text nodes instead of CDATASection?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115494</commentid>
    <comment_count>8</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-26 08:05:00 +0000</bug_when>
    <thetext>The XML specification does not define what nodes to create. My idea was always that https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html in combination with HTML&apos;s &quot;XML parser&quot; definition would define that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115495</commentid>
    <comment_count>9</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-26 08:05:30 +0000</bug_when>
    <thetext>I think if we can change the XML parser, we have a good shot at changing the rest.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115566</commentid>
    <comment_count>10</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-26 22:16:42 +0000</bug_when>
    <thetext>What should happen in the case where the XML parser would previously output a CDATASection with a preceding or following Text node? It seems odd to have sibling Text nodes, but collapsing them would be more work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115595</commentid>
    <comment_count>11</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-27 08:01:11 +0000</bug_when>
    <thetext>I think ideally it would be one node, but not having CDATASection nodes would be a good start.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115602</commentid>
    <comment_count>12</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-27 09:29:38 +0000</bug_when>
    <thetext>OK, it looks like creating a single text nodes was easier than I thought.

Simon was kind enough to grep some real data for createCDATASection:
http://krijnhoetmer.nl/irc-logs/whatwg/20141127#l-355

It&apos;s all &quot;targetNode.appendChild(document.createCDATASection(elementsObject[key]));&quot; which would work if createCDATASection() returns a Text node, so that&apos;s promising.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115627</commentid>
    <comment_count>13</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-11-27 15:55:49 +0000</bug_when>
    <thetext>Several interesting questions around removal CDATA was raised in: 
https://bugzilla.mozilla.org/show_bug.cgi?id=660660
https://www.w3.org/Bugs/Public/show_bug.cgi?id=12841</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115633</commentid>
    <comment_count>14</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-27 21:47:25 +0000</bug_when>
    <thetext>I experimented with the parser change today, and the resulting test failures were illuminating.

First, any code that looks for a CDATASection (nodeType 4) is obviously going to break.

A more problematic case is innerHTML. Before, innerHTML would return something very similar to the source, including the &quot;&lt;![CDATA[&quot; and &quot;]]&gt;&quot;. After the change, those were of course gone, and any &quot;&lt;&quot; characters in the source will be serialized as &quot;&amp;lt;&quot; instead. There was one test case which accidentally depended on this.

This makes me a bit worried. Counting instance where a CDATASection node is serialized could be useful, but finding the cases where there&apos;s an actual problem is very, very hard without actually making the change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115652</commentid>
    <comment_count>15</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-28 08:22:59 +0000</bug_when>
    <thetext>Mozilla devs, what are your thoughts on the parser change? It seems like quite the gamble without further data, but I don&apos;t know how to investigate the compat risk.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115669</commentid>
    <comment_count>16</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-28 14:13:49 +0000</bug_when>
    <thetext>Another case where serialization differences are observable is with XMLHttpRequest.send(document).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115729</commentid>
    <comment_count>17</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-12-01 12:22:15 +0000</bug_when>
    <thetext>Data for application/xhtml+xml + &lt;![CDATA[

https://gist.github.com/anonymous/bf63359fc7d45f16effc</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115732</commentid>
    <comment_count>18</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-12-01 13:15:48 +0000</bug_when>
    <thetext>(In reply to Simon Pieters from comment #17)
&gt; Data for application/xhtml+xml + &lt;![CDATA[
&gt; 
&gt; https://gist.github.com/anonymous/bf63359fc7d45f16effc

Since all of these are coupled with // or /**/ comments it seems likely that they&apos;re just for &lt;script&gt; or &lt;style&gt; without relying on the type of node produced.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122404</commentid>
    <comment_count>19</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-08-03 13:27:06 +0000</bug_when>
    <thetext>Philip indicated he&apos;s not excited about putting effort into removing this node. Ms2ger said he didn&apos;t want to add it to Servo. I guess if this is still unchanged when I&apos;m 30, we&apos;ll call it a day and add it back in.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122406</commentid>
    <comment_count>20</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-08-03 14:09:16 +0000</bug_when>
    <thetext>(In reply to Anne from comment #19)
&gt; Philip indicated he&apos;s not excited about putting effort into removing this
&gt; node. Ms2ger said he didn&apos;t want to add it to Servo. I guess if this is
&gt; still unchanged when I&apos;m 30, we&apos;ll call it a day and add it back in.

I&apos;m reliably informed that&apos;s in almost exactly a year.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127139</commentid>
    <comment_count>21</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2016-08-16 08:56:40 +0000</bug_when>
    <thetext>https://github.com/whatwg/dom/pull/295</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>