#8234 closed bug (wontfix)
Element with id="nodeName" throw exception in Chrome and IE
Reported by: | mr.albert.nicolas | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | misc | Version: | 1.5 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If the DOM contains an element with an id="nodeName", JQuery throw :
- Chrome 9
Uncaught TypeError: Object #<an HTMLDivElement> has no method 'toLowerCase' jQuery.extend.acceptDatajquery-1.5.js:1489 jQuery.extend.datajquery-1.5.js:1328 jQuery.extend._datajquery-1.5.js:1483 jQuery.event.handlejquery-1.5.js:2512 jQuery.event.add.elemData.handle.eventHandlejquery-1.5.js:2160
- IE 8
Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729) Timestamp: Thu, 10 Feb 2011 13:24:21 UTC Message: Object doesn't support this property or method Line: 1489 Char: 4 Code: 0 URI: http://code.jquery.com/jquery-1.5.js
No error with FF3.6
Here a very simple sample : http://jsfiddle.net/JFtYr/3/
Change History (4)
comment:1 Changed 13 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:2 Changed 13 years ago by
Component: | unfiled → misc |
---|---|
Priority: | undecided → low |
Hmm looks like I didn't submit my comment and snover closed the ticket in the meantime. Adding anyway:
Thanks for taking the time to contribute to the jQuery project by writing a bug report.
You should have a look at this http://bugs.jquery.com/ticket/7712#comment:5
The problem is that the div is added as expando property to the window object this makes jQuery fail because the window object then "looks like" a DOM element.
It's unlikely that this will get fixed anytime soon (as that would be highly impractical code and size-wise) and it's not a good idea to use reserved names as ID anyway. So you are well advised to read the comment I linked to above and the links in that comment and to change your id/name attributes to "sane" values.
If you can't change the id of this div you might want to try the $(document).ready(...);
syntax instead of the $(window).load(...)
(unless you specifically need the window load.
You might also want to check #3685, #7472, #7712 and similar tickets to see variations of this problem.
comment:3 follow-up: 4 Changed 12 years ago by
Getting this error with fancybox 1.3.4: It appears to be trying to pass a function to acceptData. I couldn't identify which part of the code was responsible but I used this as a quick fix: http://jsfiddle.net/jGes4/
comment:4 Changed 12 years ago by
Replying to info@…:
Getting this error with fancybox 1.3.4: It appears to be trying to pass a function to acceptData. I couldn't identify which part of the code was responsible but I used this as a quick fix: http://jsfiddle.net/jGes4/
A better alternative http://jsfiddle.net/gyXxK/
Do not use reserved DOM names as element IDs.