W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2012

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

From: <bugzilla@jessica.w3.org>
Date: Thu, 15 Nov 2012 12:50:32 +0000
To: www-dom@w3.org
Message-ID: <bug-19968-4009@http.www.w3.org/Bugs/Public/>

          Priority: P2
            Bug ID: 19968
                CC: bugs@pettay.fi, matspal@gmail.com, mike@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


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

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 on the CC list for the bug.
Received on Thursday, 15 November 2012 12:50:34 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:50:42 UTC