This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 14035 - Range + splitText handling is inconsistent
Summary: Range + splitText handling is inconsistent
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-05 18:08 UTC by Olli Pettay
Modified: 2011-12-23 14:52 UTC (History)
3 users (show)

See Also:


Attachments

Description Olli Pettay 2011-09-05 18:08:34 UTC
The behavior depends on whether the textnode has parent or not.
If there is parent, boundary point'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's node would be updated.

Also, it should be specified clearly what should happen in the case when
textnode doesn't have parent and splittext happens between the range's
boundary points. In this case the end point should probably point to the
end of the original (modified) node.
Comment 1 Anne 2011-09-07 09:05:18 UTC
If the range is fully... what?
Comment 2 Olli Pettay 2011-09-07 10:00:16 UTC
If range start and end points are after the split point.
Comment 3 Aryeh Gregor 2011-09-07 14:02:53 UTC
(In reply to comment #0)
> The behavior depends on whether the textnode has parent or not.
> If there is parent, boundary point'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'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.

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

That'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's parent is null, range's start offset is >= offset, range's end offset is > offset: set range's start/end nodes to new node, decrement range's start/end offsets by offset
* new node's parent is null, range's end node is old node, range's end offset is > offset: set range's end offset to offset (not sure why this needs a special case, though)
* new node's parent is not null, range's start offset > offset: set range's start node to new node and decrement its start offset by offset
* new node's parent is not null, range's end offset > offset: set range's end node to new node and decrement its end offset by offset
Comment 4 Olli Pettay 2011-09-07 14:20:23 UTC
(In reply to comment #3)
> Since you seem to feel strongly, we can just revert that change.  I have no
> objections.

I don'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't have
parent. And consistency, when possible, would be good.


> * new node's parent is null, range's start offset is >= offset, range's end
> offset is > offset: set range's start/end nodes to new node, decrement range's
> start/end offsets by offset
> * new node's parent is null, range's end node is old node, range's end offset
> is > offset: set range's end offset to offset (not sure why this needs a
> special case, though)
Looks ok to me.
Comment 6 Anne 2011-12-23 14:52:01 UTC
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.