Skip to main content

Bug Tracker

Side navigation

#8052 closed bug (fixed)

Opened January 25, 2011 03:34PM UTC

Closed February 07, 2011 04:57PM UTC

Last modified March 09, 2012 07:23AM UTC

IE9 document.getElementsByTagName throws an error

Reported by: thiessenp@gmail.com 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("*")

Attachments (0)
Change History (51)

Changed January 25, 2011 04:34PM UTC by addyosmani comment:1

_comment0: Could you please provide us with a reduced test case on jsFiddle.net that reproduces this error? I've just put together [http://jsfiddle.net/GqcHv/1/ 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.1295973342715983
_comment1: Could you please provide us with a reduced test case on jsFiddle.net that reproduces this error? I've just put together [http://jsfiddle.net/GqcHv/1/ 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, please clarify.1295975712192089
owner: → thiessenp@gmail.com
priority: undecidedlow
status: newpending

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.

Changed January 26, 2011 08:08AM UTC by menno.vanslooten@gmail.com comment:2

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.

Changed January 26, 2011 08:17AM UTC by jitter comment:3

_comment0: 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 type="text/javascript" src=" http://code.jquery.com/jquery-1.5rc1.js"></script> \ \ <script type="text/javascript"> \ \ var el = $('<p>how can this break IE9 - WTF?!</p>'); \ \ </script> \ \ </body> </html> \ 1296145150145734

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>

Changed January 27, 2011 04:44PM UTC by jitter comment:4

component: unfiledmanipulation
milestone: 1.next1.5.1
owner: thiessenp@gmail.comsnover
priority: lowhigh
status: pendingassigned

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.

Changed January 27, 2011 08:28PM UTC by jitter comment:5

_comment0: 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.addEventListen` should work. \ \ Dave came up with this test case http://pastie.org/15036311296160204523825

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

Changed January 28, 2011 04:31AM UTC by rwaldron comment:6

#8080 is a duplicate of this ticket.

Changed February 01, 2011 03:22AM UTC by anonymous comment:7

Was hoping this could get fixed before 1.5 as I previously pointed in (sadly my bad) in Jquery 1.5beta blog post...

Changed February 01, 2011 09:23PM UTC by ajpiano comment:8

#8133 is a duplicate of this ticket.

Changed February 02, 2011 11:51AM UTC by jitter comment:9

#8139 is a duplicate of this ticket.

Changed February 02, 2011 11:51AM UTC by jitter comment:10

priority: highblocker

Changed February 02, 2011 12:08PM UTC by Soul_Master comment:11

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
        }

Changed February 03, 2011 02:29AM UTC by jitter comment:12

#8153 is a duplicate of this ticket.

Changed February 04, 2011 04:28PM UTC by austin.fatheree+jq@gmail.com comment:13

Where do you put the above code? Right after loading jQuery? Or does it need to go in the file?

Changed February 04, 2011 04:34PM UTC by snover comment:14

_comment0: 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.1296837278585493

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.

Changed February 05, 2011 04:19PM UTC by jitter comment:15

#8183 is a duplicate of this ticket.

Changed February 07, 2011 04:57PM UTC by Colin Snover comment:16

resolution: → fixed
status: assignedclosed

Update jQuery.support.noCloneEvent test to function properly in IE9. Fixes #8052. 1.5-stable

Changeset: 534dbd660eaefbbc5827b1b61ba384e768562086

Changed February 10, 2011 08:30PM UTC by Info@3DHDSoft.com comment:17

I am using IE9 RC 9.0.8080.16413 and still getting this bug.

Ivan

Changed February 10, 2011 08:39PM UTC by anonymous comment:18

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() {

Changed February 10, 2011 09:05PM UTC by ajpiano comment:19

#8238 is a duplicate of this ticket.

Changed February 10, 2011 09:46PM UTC by Spikeon comment:20

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

Changed February 10, 2011 11:01PM UTC by zwu_ca@yahoo.com comment:21

Got the same error at http://google.elookinto.com forIE 9.0.7930.16406 (RC). It works fine with IE7,8 and firefox.

Changed February 10, 2011 11:03PM UTC by snover comment:22

_comment0: Please do not comment on this ticket with “me too”. We have already fixed this problem, as per the ticket status, and the fix will be released in 1.5.1.1297379024509965

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.

Changed February 10, 2011 11:27PM UTC by Spikeon comment:23

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?

Changed February 14, 2011 01:29AM UTC by anonymous comment:24

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?

Changed February 14, 2011 01:31AM UTC by rwaldron comment:25

Here is the 1.5.1 schedule:

RC: Feb 18th.

Final: Feb 24th.

Changed February 15, 2011 03:19AM UTC by anonymous comment:26

@rwaldron: Thanks for the info :)

Changed February 22, 2011 05:14PM UTC by ajpiano comment:27

#8349 is a duplicate of this ticket.

Changed February 22, 2011 07:47PM UTC by ajpiano comment:28

#8354 is a duplicate of this ticket.

Changed February 22, 2011 11:47PM UTC by ajpiano comment:29

#8357 is a duplicate of this ticket.

Changed February 23, 2011 04:32PM UTC by ajpiano comment:30

#8364 is a duplicate of this ticket.

Changed February 25, 2011 04:03AM UTC by anonymous comment:31

good!

Changed March 24, 2011 02:36AM UTC by anonymous comment:32

still dies not work in IE 9 .8080

Changed March 30, 2011 03:15PM UTC by qwertypants comment:33

Not working on IE9 version 9.0.8112.16421 64bit

Changed March 31, 2011 09:29PM UTC by cymbals comment:34

Replying to [comment:33 qwertypants]:

Not working on IE9 version 9.0.8112.16421

1.5.1 is still giving the same error on IE 9.8080.16413

Changed April 01, 2011 03:07PM UTC by anonymous comment:35

Still seeing this bug in 1.5 and IE 9.

Changed April 05, 2011 01:40PM UTC by joaquinrivero comment:36

Still seeing this bug in 1.5 and IE 9.

Changed April 05, 2011 03:13PM UTC by rwaldron comment:37

Please test with the latest jQuery:

http://code.jquery.com/jquery-git.js

Changed April 08, 2011 02:03PM UTC by anonymous comment:38

Still seeing this bug with 1.5.2 and IE9

Changed April 14, 2011 12:22PM UTC by deCube comment:39

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.

Changed April 15, 2011 11:58AM UTC by prashant9792@gmail.com comment:40

Hello Sir,

I have use flexigrid it works in every browser but not works in IE9 and the same error is occur

Changed April 15, 2011 09:10PM UTC by anonymous comment:41

Still a bug in IE 9.0.8112.16421

Changed April 15, 2011 11:45PM UTC by rwaldron comment:42

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.

Changed April 22, 2011 10:28PM UTC by reedlauber comment:43

Was having the issue with 1.5.2, but switching to the Git version cleared it up.

Changed May 16, 2011 01:14PM UTC by anonymous comment:44

I had a problem today with IE9 using 1.5.2 also. I downloaded 1.6.1 and it cleared up the issue.

Changed May 25, 2011 10:38PM UTC by paul comment:45

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.

Changed June 02, 2011 01:26PM UTC by chris.sloan comment:46

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.

Changed June 02, 2011 03:33PM UTC by rwaldron comment:47

This will fail in IE <9

Changed June 09, 2011 07:15AM UTC by dj.sidali@gmail.com comment:48

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.

Changed June 28, 2011 03:47PM UTC by anonymous comment:49

Replying to [ticket:8052 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

Changed July 11, 2011 04:31PM UTC by zorba comment:50

Replying to [comment:46 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

Changed September 01, 2011 01:32PM UTC by anonymous comment:51

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