#4351 closed bug (worksforme)
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: |
Description
The problem pops up on line 714 of the selector component (http://dev.jquery.com/browser/trunk/jquery/src/selector.js). 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 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: http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113/ranges.html#Level2-Range-method-selectNode
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 :)
Change History (6)
comment:1 Changed 14 years ago by
comment:3 Changed 14 years ago by
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="http://google.com"><img vspace="4" hspace="4" border="0" alt="" src=""></a><br></div>Some text <a href="http://google.com/">text</a> more text<a href="http://google.com/">text again</a>, Even more text<a href="http://google.com/"> and again</a> and even more text.</div>');
alert('TEST');
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)
comment:4 Changed 14 years ago by
Hello,
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: http://groups.google.com/group/jquery-en/browse_thread/thread/1150ccc5548a7de8/7c06d65d8aed3e91?lnk=raot&pli=1
comment:6 Changed 12 years ago by
Keywords: | INVALID_NODE_TYPE_ERR added |
---|---|
Resolution: | → worksforme |
Status: | new → closed |
Testing this bug with jQuery 1.4.4 RC2, Chrome (7) appears to behave in the same expected way that other browsers do http://jsfiddle.net/addyosmani/ewcTp/1/. Closing this ticket unless there is further information confirming the issue still existing to the contrary.
I'm sorry. I got the line number wrong. It's line number 725 [aRange.selectNode(a);] in file http://dev.jquery.com/browser/trunk/jquery/src/selector.js
714 contained the keyword I searched for.