Bug 22684 - Creating a range with a boundary node's ancestor not in the DOM throws INVALID_NODE_TYPE_ERR
Summary: Creating a range with a boundary node's ancestor not in the DOM throws INVAL...
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-05 10:55 PST by Benoit Marchant
Modified: 2023-04-11 15:26 PDT (History)
5 users (show)

See Also:


Attachments
test case (343 bytes, text/html)
2009-11-15 17:12 PST, Alexey Proskuryakov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Benoit Marchant 2008-12-05 10:55:46 PST
Creating a range with boundary a node for which an ancestor is not actually in the DOM throw an  INVALID_NODE_TYPE_ERR  exception  :

		 var hiddenDOMRange = window.document.createRange(),
			startNode = ... /*a DOM node for which one of it's ancestor has a parentNode null, although they have the right ownerDocument*/;
 
		 hiddenDOMRange.setStartBefore(startNode);//This call will throw an exception

Works as expected in FireFox
Comment 1 Brad 2009-11-15 10:28:47 PST
Is there any progress on this bug? I am encountering it when using tinyMCE.  Reproduction: In a tinymce editor, add a table, some rows and some columns.  Then, for that editor, call getContent (in tinymce).
Comment 2 Alexey Proskuryakov 2009-11-15 17:12:15 PST
Created attachment 43258 [details]
test case
Comment 3 Alexey Proskuryakov 2009-11-15 17:13:40 PST
Confirmed with r50998.
Comment 4 Alexey Proskuryakov 2009-11-15 17:38:08 PST
Looks like WebKit behavior is correct per <http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html> though:

"INVALID_NODE_TYPE_ERR: Raised if the root container of refNode is not an Attr, Document, or DocumentFragment node or if refNode is a Document, DocumentFragment, Attr, Entity, or Notation node." In the attached test case, root container is an Element node.

Also, "... the content of a Range must be entirely within the subtree rooted by a single Document, DocumentFragment or Attr Node", per paragraph 2.2.1.
Comment 5 Lucas Forschler 2019-02-06 09:03:47 PST
Mass moving XML DOM bugs to the "DOM" Component.
Comment 6 Ahmad Saleem 2023-04-11 15:10:19 PDT
All browsers (Safari 16.4, Chrome Canary 114 and Firefox Nightly 114) show alert with "No Exception", do we need to do anything here or we can mark this as "RESOLVED CONFIGURATION CHANGED"? Thanks!