<?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>14035</bug_id>
          
          <creation_ts>2011-09-05 18:08:34 +0000</creation_ts>
          <short_desc>Range + splitText handling is inconsistent</short_desc>
          <delta_ts>2011-12-23 14:52:01 +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>PC</rep_platform>
          <op_sys>Linux</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>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Olli Pettay">bugs</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>ayg</cc>
    
    <cc>mike</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>56341</commentid>
    <comment_count>0</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-09-05 18:08:34 +0000</bug_when>
    <thetext>The behavior depends on whether the textnode has parent or not.
If there is parent, boundary point&apos;s node can be changed, 
but if not, range is possibly just collapsed to the end of the
original text node.

I would expect that if the range is fully after the split point, the
range&apos;s node would be updated.

Also, it should be specified clearly what should happen in the case when
textnode doesn&apos;t have parent and splittext happens between the range&apos;s
boundary points. In this case the end point should probably point to the
end of the original (modified) node.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56460</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-09-07 09:05:18 +0000</bug_when>
    <thetext>If the range is fully... what?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56461</commentid>
    <comment_count>2</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-09-07 10:00:16 +0000</bug_when>
    <thetext>If range start and end points are after the split point.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56469</commentid>
    <comment_count>3</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-09-07 14:02:53 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; The behavior depends on whether the textnode has parent or not.
&gt; If there is parent, boundary point&apos;s node can be changed, 
&gt; but if not, range is possibly just collapsed to the end of the
&gt; original text node.
&gt; 
&gt; I would expect that if the range is fully after the split point, the
&gt; range&apos;s node would be updated.

This is what the spec used to say, but I changed it because it seemed like pointless extra complexity:

https://bitbucket.org/ms2ger/dom-range/changeset/c622a27735ff

Since you seem to feel strongly, we can just revert that change.  I have no objections.

&gt; Also, it should be specified clearly what should happen in the case when
&gt; textnode doesn&apos;t have parent and splittext happens between the range&apos;s
&gt; boundary points. In this case the end point should probably point to the
&gt; end of the original (modified) node.

That&apos;s what the spec said before I changed it, yeah.  The four special cases for oldNode.splitText(offset) were (before I changed it):

* new node&apos;s parent is null, range&apos;s start offset is &gt;= offset, range&apos;s end offset is &gt; offset: set range&apos;s start/end nodes to new node, decrement range&apos;s start/end offsets by offset
* new node&apos;s parent is null, range&apos;s end node is old node, range&apos;s end offset is &gt; offset: set range&apos;s end offset to offset (not sure why this needs a special case, though)
* new node&apos;s parent is not null, range&apos;s start offset &gt; offset: set range&apos;s start node to new node and decrement its start offset by offset
* new node&apos;s parent is not null, range&apos;s end offset &gt; offset: set range&apos;s end node to new node and decrement its end offset by offset</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56470</commentid>
    <comment_count>4</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-09-07 14:20:23 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; Since you seem to feel strongly, we can just revert that change.  I have no
&gt; objections.

I don&apos;t feel really strongly either way, but the spec must be easy to read.
Currently it is too difficult to figure out what should happen when text node doesn&apos;t have
parent. And consistency, when possible, would be good.


&gt; * new node&apos;s parent is null, range&apos;s start offset is &gt;= offset, range&apos;s end
&gt; offset is &gt; offset: set range&apos;s start/end nodes to new node, decrement range&apos;s
&gt; start/end offsets by offset
&gt; * new node&apos;s parent is null, range&apos;s end node is old node, range&apos;s end offset
&gt; is &gt; offset: set range&apos;s end offset to offset (not sure why this needs a
&gt; special case, though)
Looks ok to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56472</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-09-07 15:41:28 +0000</bug_when>
    <thetext>https://bitbucket.org/ms2ger/dom-core/changeset/f99128922c3d

http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-text-split

Thanks guys!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61979</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-12-23 14:52:01 +0000</bug_when>
    <thetext>I changed it slightly to be more Gecko and test suite compatible.

http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-text-split
https://bitbucket.org/ms2ger/dom-core/changeset/c2f6b94c2352

In particular if there is no parent node the range will never be transfered to the new node.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>