Skip to main content

Bug Tracker

Side navigation

#4351 closed bug (worksforme)

Opened March 14, 2009 12:39AM UTC

Closed November 08, 2010 07:11AM UTC

Last modified March 14, 2012 02:11PM UTC

INVALID_NODE_TYPE_ERR Uncaught exception / Selector engine

Reported by: 357.gaby Owned by: john
Priority: major Milestone: 1.4
Component: selector Version: 1.3.2
Keywords: exception INVALID_NODE_TYPE_ERR Cc:
Blocked by: Blocking:

The problem pops up on line 714 of the selector component (

As far as I can tell it only happens in Google Chrome. The reason for this is that only chrome enters that branch of the functions definition (For explorer it goes to ["sourceIndex" in document.documentElement], and for Firefox/Safari 4 it goes to [document.documentElement.compareDocumentPosition]).

This is the W3 spec for this method and relevant exception:

I guess the error will probably disappear as soon as Chrome switches to the new WebKit engine (because that implements document.documentElement.compareDocumentPosition).

Unfortunately I don't have a popper test case. I'm working with some rather dynamic html content and as far as I have read and been able to test, the exception shouldn't happen. Unfortunately I haven't had much time to properly test this.

Nonetheless, no matter what html I give it, the error (Uncaught exception) really shouldn't happen.

I'm not very familiar with the operations the selector does so I can't really propose anything more than a try catch to fix this; as far as I can tell that will probably not affect the engine all that much (All the nodes will have an equal position, but the sortOrder function seems to be kind of optional (Before it's used there's a check for it's existence)).

Sorry for the general sloppiness of this ticket. It's 2:30 am :)

Attachments (0)
Change History (6)

Changed March 14, 2009 12:42AM UTC by 357.gaby comment:1

I'm sorry. I got the line number wrong.

It's line number 725 [aRange.selectNode(a);] in file

714 contained the keyword I searched for.

Changed March 14, 2009 01:01AM UTC by dmethvin comment:2

What jQuery code causes the error to be thrown?

Changed March 14, 2009 09:15AM UTC by 357.gaby comment:3

I've managed to make a test case (kind of).

The exception is always thrown (in Chrome) when the following code is run:

var _$t = $('<div id="big_id"><p></p><p></p><div align="center"><a href=""><img vspace="4" hspace="4" border="0" alt="" src=""></a><br></div>Some text <a href="">text</a> more text<a href="">text again</a>, Even more text<a href=""> and again</a> and even more text.</div>');


// remove all empty elements

_$t.find(':empty').not('img, br, hr');

alert('TEST END');

I would have trimmed the html more, but I didn't have time.

Anyway, that should pretty much make everything clear.

Also, it doesn't matter how I try to find the empty elements (eg, I can try a more complicated selector (with :not) instead of the two consecutive selectors, but it will still die)

Changed March 16, 2009 04:26PM UTC by oracio comment:4


I have the same problem with Adobe AIR, which uses this old Webkit version aswell.

I get the "Error: INVALID_NODE_TYPE_ERR: DOM Range Exception 2" error when I try to use .datepicker('distroy') (happens in all the widgets) or even on .empty().

I was using jQuery1.3.2 and I had to downgrade to 1.3.1 which fixed this issue.

Unfortunately I can't provide a live example but you can see that this is not the first time that people get this error:

Changed March 16, 2009 04:28PM UTC by oracio comment:5

i meant .datepicker('destroy') of course...

Changed November 08, 2010 07:11AM UTC by addyosmani comment:6

keywords: exceptionexception INVALID_NODE_TYPE_ERR
resolution: → worksforme
status: newclosed

Testing this bug with jQuery 1.4.4 RC2, Chrome (7) appears to behave in the same expected way that other browsers do Closing this ticket unless there is further information confirming the issue still existing to the contrary.