#8052 closed bug (fixed)
IE9 document.getElementsByTagName throws an error
Reported by: | Owned by: | snover | |
---|---|---|---|
Priority: | blocker | Milestone: | 1.5.1 |
Component: | manipulation | Version: | 1.5rc1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In IE9 (beta) it looks like document.getElementsByTag name isn't supported.
JQuery line 5456 throws an error: "Object doesn't support this property or method..." for code elem.document.getElementsByTag("*")
Change History (51)
comment:1 Changed 12 years ago by
Owner: | set to thiessenp@… |
---|---|
Priority: | undecided → low |
Status: | new → pending |
comment:2 Changed 12 years ago by
Hey Addy,
Your test works in jsFiddle because it changes the document mode to IE7 (jsFiddle doesn't work in IE9 mode). The bug only happens in IE9 mode.
comment:3 Changed 12 years ago by
Something as basic as the below throws an exception in IE.
Note: comment above about JSFiddle in IE9 document mode Note: I tried with a HTML4 and HTML5 doc type Note: Please disregard the new bug I opened: Ticket #8062
<!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.01EN" " http://www.w3.org/TR/html4/strict.dtd"> <html> <head></head> <body> <script src=" http://code.jquery.com/jquery-1.5rc1.js"></script> <script> var el = $('<p>how can this break IE9 - WTF?!</p>'); </script> </body> </html>
comment:4 Changed 12 years ago by
Component: | unfiled → manipulation |
---|---|
Milestone: | 1.next → 1.5.1 |
Owner: | changed from thiessenp@… to snover |
Priority: | low → high |
Status: | pending → assigned |
This bug was introduced by the recent optimizations to the clone()
method. Specifically with this commit.
As the variables elem
and clone
both can be DocumentFragments it's not safe to call getElementsByTagName
on them. Because according to the specification DocumentFragements don't implement this method. The reason older IE versions don't trip over this is that they implement this method on DocumentFragments too although they shouldn't. IE9 seems to have fixed this (becoming more spec following) and removed the method and now breaks when hitting this branch.
A possible fix would be to check if elem/clone are nodeType === 11
then check if elem/clone.getElementsByTagName
is available if yes use it. If no resort to elem/clone.querySelectorAll("*")
. This should be fine as older IE versions have getElementsByTagName
and newer versions have querySelectorAll
.
Another idea would be something along the lines of what John did in Sizzle in this commit (was later removed).
Targeted this for 1.5.1 but maybe we want to fix this before already for 1.5.
comment:5 Changed 12 years ago by
After some more discussion and looking into this we figured out that maybe we can just leave the branch as is and instead fix the noCloneEvent
support test. It looks like IE9 finally supports addEventListener
and does no longer clone events. So adding !div.addEventListener
should work.
Dave came up with this test case http://pastie.org/1503631
comment:7 Changed 12 years ago by
Was hoping this could get fixed before 1.5 as I previously pointed in (sadly my bad) in Jquery 1.5beta blog post...
comment:10 Changed 12 years ago by
Priority: | high → blocker |
---|
comment:11 Changed 12 years ago by
I use the following code to temporary fix this bug. Everything works fine on IE9 post-beta.
// Soul_Master custom bug fix for ticket #8052 if ( jQuery.browser.msie && jQuery.browser.version >= 9 ) { jQuery.support.noCloneEvent = true }
comment:13 Changed 12 years ago by
Where do you put the above code? Right after loading jQuery? Or does it need to go in the file?
comment:14 Changed 12 years ago by
Please do not use the code prescribed by Soul_Master. It is quite wrong. If you want to work around this problem, use jQuery.support.noCloneEvent = !!window.addEventListener
instead. It will be resolved in 1.5.1.
comment:16 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Update jQuery.support.noCloneEvent test to function properly in IE9. Fixes #8052. 1.5-stable
Changeset: 534dbd660eaefbbc5827b1b61ba384e768562086
comment:17 Changed 12 years ago by
I am using IE9 RC 9.0.8080.16413 and still getting this bug.
Ivan
comment:18 Changed 12 years ago by
This did the trick for me :-)
jQuery.support.deleteExpando = false; } - if ( div.attachEvent && div.fireEvent ) { + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { div.attachEvent("onclick", function click() {
comment:20 Changed 12 years ago by
I am having this problem ONLY when my doctype is set to XHtml 1.0, using IE 9.0.7930.16406.
It functions Perfectly in Chrome 9.0.597.94 and Firefox 3.6.13
I would also like to mention that i am NOT using the tag that is causing this error. it is erroring out, and subsequently crashing all of my jquery at: SCRIPT438: Object doesn't support this property or method - jquery-latest.pack.js, line 16, character 59007
comment:21 Changed 12 years ago by
Got the same error at http://google.elookinto.com forIE 9.0.7930.16406 (RC). It works fine with IE7,8 and firefox.
comment:22 Changed 12 years ago by
Please do not comment on this ticket. We have already fixed this problem, as per the ticket status, and the fix will be released in 1.5.1.
comment:23 Changed 12 years ago by
when will 1.5.1 be released? or will it work if i roll back to a previous release until 1.5.1 comes out?
comment:24 Changed 12 years ago by
This bug essentially blocks upgrading to 1.5, really need an ETA for 1.5.1 for planning purposes. Alternatively can you confirm a complete workaround? Can we just sub in your code to soul_master's example?
comment:34 Changed 12 years ago by
Replying to qwertypants:
Not working on IE9 version 9.0.8112.16421
1.5.1 is still giving the same error on IE 9.8080.16413
comment:39 Changed 12 years ago by
This bug is still occurring in IE 9.0.8112.16421, jQuery v1.5.2.
Hope it'll be fixed in the next version, for now I have to use a quick fix.
comment:40 Changed 12 years ago by
Hello Sir, I have use flexigrid it works in every browser but not works in IE9 and the same error is occur
comment:42 Changed 12 years ago by
Can anyone please confirm that the LATEST version of jQuery (1.6 beta 1) is still having this issue in IE9? Please provide the test case that is used to confirm this - thank you.
comment:43 Changed 12 years ago by
Was having the issue with 1.5.2, but switching to the Git version cleared it up.
comment:44 Changed 12 years ago by
I had a problem today with IE9 using 1.5.2 also. I downloaded 1.6.1 and it cleared up the issue.
comment:45 Changed 12 years ago by
I had a problem with 1.5.1 so moved to 1.6.1 - but am still having problems. This is only with IE9, IE8 works fine.
comment:46 follow-up: 50 Changed 12 years ago by
I ran into this same problem yesterday and ended up replacing all references to:
.getElementsByTagName("*")
with
.querySelectorAll("*")
in the jQuery.min.js file (1.6.1). Yes, 1.6.1 didn't fix the issue, so I had to hack it together temporarily. Haven't seen any other issues yet in other browsers so it seems to do just fine and IE9 is fixed.
comment:48 Changed 12 years ago by
jQuery 1.5.1 has now been released and now works with IE9 RC, you can link to it from both Google and Microsoft CDNs:
Microsoft CDN: http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.min.js
Tested.
comment:49 Changed 12 years ago by
Replying to thiessenp@…:
In IE9 (beta) it looks like document.getElementsByTag name isn't supported.
JQuery line 5456 throws an error: "Object doesn't support this property or method..." for code elem.document.getElementsByTag("*")
HI I facing the same issue can any one fix this at the earliest. I have a screen capture of it how to past that on this comment? When i run the web site on IE 9 compatibility mode it works fine.
i am using jquery-1.5.min.js.
please help
comment:50 Changed 12 years ago by
Replying to chris.sloan:
I ran into this same problem yesterday and ended up replacing all references to:
.getElementsByTagName("*")with
.querySelectorAll("*")
in the jQuery.min.js file (1.6.1). Yes, 1.6.1 didn't fix the issue, so I had to hack it together temporarily. Haven't seen any other issues yet in other browsers so it seems to do just fine and IE9 is fixed.
Could anybody confirm that this simple change will make jQuery.min.js file (1.6.1) work fine with any browser ? I could'nt test all... Thanks a lot
comment:51 Changed 12 years ago by
It is a bad idea, to change used method, it can displays on preformans. As temporary solve you can use meta header for IE: <meta http-equiv="X-UA-Compatible" content="IE=8">
Type previous code in your head section, and it will switch IE9 into IE8 rendering mode, where is no problems with jquery. Beware, make sure that your markup displays corectly in IE8.
In the new version of jquery ( tested on 1.6.2 ) this bug is fixed
Could you please provide us with a reduced test case on jsFiddle.net that reproduces this error? I've just put together this simple test and everything seems to be working fine in IE9 beta with the 1.5RC. Please also let us know if you're testing in a particular standards mode.
PS: Also bare in mind I'm assuming you're referring to getElementsByTagName. If not, let us know.