[Bug 19968] New: splitText() can create ranges with end before start

https://www.w3.org/Bugs/Public/show_bug.cgi?id=19968

          Priority: P2
            Bug ID: 19968
                CC: bugs@pettay.fi, matspal@gmail.com, mike@w3.org,
                    www-dom@w3.org
          Assignee: annevk@annevk.nl
           Summary: splitText() can create ranges with end before start
        QA Contact: public-webapps-bugzilla@w3.org
          Severity: normal
    Classification: Unclassified
                OS: All
          Reporter: ayg@aryeh.name
          Hardware: All
            Status: NEW
           Version: unspecified
         Component: DOM
           Product: WebAppsWG

Test-case:

data:text/html,<!doctype html>
abcdef<br>
<script>
document.body.firstChild.splitText(3);
var range = document.createRange();
range.setStart(document.body.firstChild, 2);
range.setEnd(document.body, 1);
document.body.firstChild.splitText(1);
document.body.appendChild(document.createTextNode(
"(" + range.startContainer.nodeName + " " + range.startContainer.nodeValue
+ ", " + range.startOffset
+ ") (" + range.endContainer.nodeName + " " + range.endContainer.nodeValue
+ ", " + range.endOffset + ")"));
</script>

Gecko and WebKit give "(#text bc, 1) (BODY null, 1)" -- where the node "#text
bc" is the second child of <body>, so the end is before the start.  Opera gives
"(#text bc, 1) (#text bc, 1)", which makes no sense but at least isn't
backwards.  IE gives "(#text bc, 2) (BODY null, 1)", which is the most broken
of all.  The spec requires Gecko/WebKit behavior, and is thus obviously wrong.

Mats Palmgren explains the problem in detail in this Mozilla bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=803924#c19  He also gives a
suggested fix, namely to have splitText() explicitly handle the case where a
boundary point falls at the insertion point of the new node.  His fix looks
good to me.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Thursday, 15 November 2012 12:50:34 UTC