<?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>12205</bug_id>
          
          <creation_ts>2011-02-28 20:20:04 +0000</creation_ts>
          <short_desc>Make ProcessingInstruction implement CharacterData</short_desc>
          <delta_ts>2011-09-01 09:54:42 +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>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Aryeh Gregor">ayg</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>adrianba</cc>
    
    <cc>ap</cc>
    
    <cc>bugs</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>jonas</cc>
    
    <cc>mike</cc>
    
    <cc>mjs</cc>
    
    <cc>ojan</cc>
    
    <cc>tross</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>46101</commentid>
    <comment_count>0</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-02-28 20:20:04 +0000</bug_when>
    <thetext>All DOM specs have to deal with ProcessingInstructions for completeness, and it would be simpler if we could just deal with them at the same time as Comments and Text nodes instead of special-casing them.  Currently we often can&apos;t, because their &quot;data&quot; attribute isn&apos;t actually the same as CharacterData&apos;s and they don&apos;t have all the handy features.  Example where PIs need to be special-cased:

http://html5.org/specs/dom-range.html#concept-node-length

It&apos;s also coming up when I&apos;m speccing Range.deleteContents().  Browsers don&apos;t make PIs implement CharacterData right now, but I can&apos;t imagine it would be more than a few lines&apos; change; and since no one uses XML, I find it hard to believe there&apos;d be any compat problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46103</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-02-28 20:54:12 +0000</bug_when>
    <thetext>This would be more than a few line&apos;s change.  In particular, right now you can&apos;t position a Range inside a PI, right?  Would you be able to if it were a CharacterData?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46117</commentid>
    <comment_count>2</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-02-28 23:56:09 +0000</bug_when>
    <thetext>Per the DOM Range spec, you can position a Range inside a PI right now.  The only thing you can&apos;t put it in is a DocumentType.  Test-case:

data:application/xhtml+xml,
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;head&gt;&lt;script&gt;
var pi = document.createProcessingInstruction(&quot;a&quot;, &quot;abc&quot;);
var range = document.createRange();
range.selectNodeContents(pi);
alert(range.startContainer);
&lt;/script&gt;&lt;/head&gt;&lt;/html&gt;

Opera 11 throws a BAD_BOUNDARYPOINTS_ERR, but Firefox 4b11 and Chrome 11 dev both alert [object ProcessingInstruction].</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46124</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-03-01 01:54:13 +0000</bug_when>
    <thetext>Ah, I see.  Hmm.  It looks like we may in fact share the same code as Text and CDATA nodes for ProcessingInstruction in Gecko, ok.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46318</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-03-04 13:13:02 +0000</bug_when>
    <thetext>This should be no problem for Opera. What do other implementors think?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46320</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-03-04 13:43:41 +0000</bug_when>
    <thetext>(Remember to credit Daniel Bratell for information on Opera if we decide to do this.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46321</commentid>
    <comment_count>6</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-03-04 13:52:09 +0000</bug_when>
    <thetext>So selecting parts of PI data using range would become possible?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46322</commentid>
    <comment_count>7</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-03-04 13:54:42 +0000</bug_when>
    <thetext>As stated in comment 2 you already can.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46323</commentid>
    <comment_count>8</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-03-04 14:01:26 +0000</bug_when>
    <thetext>No. Comment 2 says you can put PI as container, but it does not test
if one can select part of the data.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46324</commentid>
    <comment_count>9</comment_count>
      <attachid>964</attachid>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-03-04 14:06:23 +0000</bug_when>
    <thetext>Created attachment 964
a testcase</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46325</commentid>
    <comment_count>10</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-03-04 14:09:07 +0000</bug_when>
    <thetext>But still, I think this change does make sense.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46326</commentid>
    <comment_count>11</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-03-04 14:41:38 +0000</bug_when>
    <thetext>I assume selecting comment node&apos;s data should become supported too?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46327</commentid>
    <comment_count>12</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-03-04 14:53:00 +0000</bug_when>
    <thetext>
(In reply to comment #9)
&gt; Created attachment 964 [details]
&gt; a testcase

Ah, actually, this just shows similar bug in Gecko and Webkit since
&quot;If the container is a CharacterData, Comment or ProcessingInstruction node, the offset is between the 16-bit units of the UTF-16 encoded string contained by it.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46340</commentid>
    <comment_count>13</comment_count>
      <attachid>966</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-03-04 17:14:59 +0000</bug_when>
    <thetext>Created attachment 966
selecting PI content

You can select PI data in WebKit, it&apos;s just toString() only collecting data from TEXT_NODE and CDATA_SECTION_NODE nodes. As far as I can tell, the same is true for Gecko, and it appears to be quite reasonable behavior.

Furthermore, Range.deleteContents works with PIs in WebKit, but not in Gecko (tested with Firefox 3.6).

I&apos;m not sure if adding CharacterData methods like appendData() or insertData() to PI makes a lot of sense.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46341</commentid>
    <comment_count>14</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-03-04 17:20:32 +0000</bug_when>
    <thetext>Seems like deleteContents would just work on Gecko if
PI was CharacterData. ToString() would need still some work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46342</commentid>
    <comment_count>15</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2011-03-04 17:24:30 +0000</bug_when>
    <thetext>Seems like IE&apos;s current behaviour is currently closest to what Opera does. This seems like an edge-case, though, so without a strong use case it probably wouldn&apos;t be a high priority for us to spend time on. Is there a reason why this is important to change?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46347</commentid>
    <comment_count>16</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-03-04 17:48:45 +0000</bug_when>
    <thetext>(In reply to comment #13)
&gt; You can select PI data in WebKit, it&apos;s just toString() only collecting data
&gt; from TEXT_NODE and CDATA_SECTION_NODE nodes. As far as I can tell, the same is
&gt; true for Gecko, and it appears to be quite reasonable behavior.

Yes, this is what the spec requires.  toString() on a Range is basically like textContent, it only hits text nodes.

&gt; Furthermore, Range.deleteContents works with PIs in WebKit, but not in Gecko
&gt; (tested with Firefox 3.6).

Yep, I was just writing some tests for deleteContents() and I noticed that (the processingInstruction test):

http://aryeh.name/spec/dom-range/test/Range-deleteContents.html

(In reply to comment #15)
&gt; Seems like IE&apos;s current behaviour is currently closest to what Opera does. This
&gt; seems like an edge-case, though, so without a strong use case it probably
&gt; wouldn&apos;t be a high priority for us to spend time on. Is there a reason why this
&gt; is important to change?

No, it would just make the specs a bit simpler, allowing us to avoid some edge-cases in general in the specs (and I imagine in code too).  There&apos;s no reason implementers need to be in any hurry to actually change their implementations anytime soon, as long as they aren&apos;t averse to changing them in principle.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>47140</commentid>
    <comment_count>17</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-04-04 20:14:50 +0000</bug_when>
    <thetext>Okay, after consultation with Ms2ger, I&apos;m going to solve this by just prohibiting ProcessingInstructions from being Range endpoints, like DocumentTypes.  IE and Opera already do this, and it will be easier for Gecko/WebKit to implement than the alternative.  I&apos;m fine if this bug is closed WONTFIX.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49857</commentid>
    <comment_count>18</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-06-19 15:49:53 +0000</bug_when>
    <thetext>I still think it makes sense to pursue this though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49862</commentid>
    <comment_count>19</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2011-06-19 21:48:11 +0000</bug_when>
    <thetext>I&apos;d be ok with adding CharacterData to PIs. However I also don&apos;t see any big benefits in doing so. We still have to deal with non-characterdata elements appearing in the tree in the form of doctypes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51492</commentid>
    <comment_count>20</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-07-26 16:51:20 +0000</bug_when>
    <thetext>Yeah, not much is solved by this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51980</commentid>
    <comment_count>21</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-08-02 10:16:05 +0000</bug_when>
    <thetext>Actually, I want to reconsider. The difference with doctypes is that doctypes are not mutable. ProcessingInstruction.data is mutable in the exact same way Text.data and Comment.data are mutable. As such it makes a lot of sense to group them together.

If we do not want to expose the methods of CharacterData on ProcessingInstruction we could put another interface between CharacterData and Text/Comment that has them or put them on Text/Comment directly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56109</commentid>
    <comment_count>22</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-08-31 14:01:16 +0000</bug_when>
    <thetext>This simplifies range handling, we should just do this.

I would implement this (or accept patches ;)) for Gecko.


Nowhere near top priority thing of course.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56164</commentid>
    <comment_count>23</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-09-01 09:54:42 +0000</bug_when>
    <thetext>Lets do this.

https://bitbucket.org/ms2ger/dom-core/changeset/ec64d3d1852d</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>964</attachid>
            <date>2011-03-04 14:06:23 +0000</date>
            <delta_ts>2011-03-04 14:06:23 +0000</delta_ts>
            <desc>a testcase</desc>
            <filename>rangepi.xhtml</filename>
            <type>application/xhtml+xml</type>
            <size>470</size>
            <attacher name="Olli Pettay">bugs</attacher>
            
              <data encoding="base64">PD94bWwgdmVyc2lvbj0iMS4wIj8+CjxodG1sIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5
L3hodG1sIj48aGVhZD48c2NyaXB0Pgp2YXIgcyA9ICJmb29QQVNTZm9vIjsKdmFyIHBpID0gZG9j
dW1lbnQuY3JlYXRlUHJvY2Vzc2luZ0luc3RydWN0aW9uKCJhIiwgcyk7CnZhciByMSA9IGRvY3Vt
ZW50LmNyZWF0ZVJhbmdlKCk7CnIxLnNldFN0YXJ0KHBpLCAzKTsKcjEuc2V0RW5kKHBpLCA3KTsK
YWxlcnQoIkRhdGEgc2VsZWN0aW9uIHVzaW5nIFBJOiAiICsgcjEudG9TdHJpbmcoKSk7Cgp2YXIg
dCA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKHMpOwp2YXIgcjIgPSBkb2N1bWVudC5jcmVhdGVS
YW5nZSgpOwpyMi5zZXRTdGFydCh0LCAzKTsKcjIuc2V0RW5kKHQsIDcpOwphbGVydCgiRGF0YSBz
ZWxlY3Rpb24gdXNpbmcgdGV4dCBub2RlOiAiICsgcjIudG9TdHJpbmcoKSk7Cgo8L3NjcmlwdD48
L2hlYWQ+PC9odG1sPgo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>966</attachid>
            <date>2011-03-04 17:14:59 +0000</date>
            <delta_ts>2011-03-04 17:14:59 +0000</delta_ts>
            <desc>selecting PI content</desc>
            <filename>rangepi.xhtml</filename>
            <type>application/xhtml+xml</type>
            <size>388</size>
            <attacher name="Alexey Proskuryakov">ap</attacher>
            
              <data encoding="base64">PD94bWwgdmVyc2lvbj0iMS4wIj8+CjxodG1sIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5
L3hodG1sIj48aGVhZD48c2NyaXB0Pgp2YXIgcyA9ICJmb29QQVNTZm9vIjsKdmFyIHBpID0gZG9j
dW1lbnQuY3JlYXRlUHJvY2Vzc2luZ0luc3RydWN0aW9uKCJhIiwgcyk7CnZhciByMSA9IGRvY3Vt
ZW50LmNyZWF0ZVJhbmdlKCk7CnIxLnNldFN0YXJ0KHBpLCAzKTsKcjEuc2V0RW5kKHBpLCA3KTsK
YWxlcnQocjEuc3RhcnRDb250YWluZXIgKyAiIC0gIiArIHIxLnN0YXJ0T2Zmc2V0ICsgIiwgIiAr
IHIxLmVuZE9mZnNldCkKcjEuZGVsZXRlQ29udGVudHMoKTsKYWxlcnQoIkFmdGVyIGRlbGV0ZUNv
bnRlbnRzOiAiICsgcGkuZGF0YSk7Cjwvc2NyaXB0PjwvaGVhZD48L2h0bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>