[Webkit-unassigned] [Bug 97361] New: range.selectNode throws INVALID_NODE_TYPE_ERR unless node has Document/DocumentFragment ancestor

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Sep 21 14:24:00 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=97361

           Summary: range.selectNode throws INVALID_NODE_TYPE_ERR unless
                    node has Document/DocumentFragment ancestor
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: All
        OS/Version: Unspecified
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: HTML DOM
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: natevw at yahoo.com


The following code fails unexpectedly in WebKit (works in FF, haven't tested IE):

    var range = document.createRange(),
        root = document.createElement('div');
    root.appendChild(document.createElement('span'));
    range.selectNode(root.firstChild);              // throws INVALID_NODE_TYPE_ERR

It is possible to `range.selectNodeContents(root)` or `range.setStart(root,0), range.setEnd(root,1)` but the `.selectNode` method specifically, errors when it should not. Reference: http://www.w3.org/TR/dom/#dom-range-selectnode — only case INVALID_NODE_TYPE_ERR should be thrown is if root.firstChild.parentNode is null...but that's unpossible!

Hooking the root element into a document, or even a document fragment via e.g. `document.createDocumentFragment().append(root)`, causes the bug to no longer manifest.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list