Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#8052 closed bug (fixed)

IE9 document.getElementsByTagName throws an error

Reported by: thiessenp@… 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 addyosmani

Owner: set to thiessenp@…
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.

Version 0, edited 12 years ago by addyosmani (next)

comment:2 Changed 12 years ago by menno.vanslooten@…

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 thiessenp

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>
Last edited 12 years ago by jitter (previous) (diff)

comment:4 Changed 12 years ago by jitter

Component: unfiledmanipulation
Milestone: 1.next1.5.1
Owner: changed from thiessenp@… to snover
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.

comment:5 Changed 12 years ago by jitter

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

Last edited 12 years ago by jitter (previous) (diff)

comment:6 Changed 12 years ago by Rick Waldron

#8080 is a duplicate of this ticket.

comment:7 Changed 12 years ago by anonymous

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

comment:8 Changed 12 years ago by ajpiano

#8133 is a duplicate of this ticket.

comment:9 Changed 12 years ago by jitter

#8139 is a duplicate of this ticket.

comment:10 Changed 12 years ago by jitter

Priority: highblocker

comment:11 Changed 12 years ago by Soul_Master

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:12 Changed 12 years ago by jitter

#8153 is a duplicate of this ticket.

comment:13 Changed 12 years ago by austin.fatheree+jq@…

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 snover

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.

Last edited 12 years ago by snover (previous) (diff)

comment:15 Changed 12 years ago by jitter

#8183 is a duplicate of this ticket.

comment:16 Changed 12 years ago by Colin Snover

Resolution: fixed
Status: assignedclosed

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

Changeset: 534dbd660eaefbbc5827b1b61ba384e768562086

comment:17 Changed 12 years ago by Info@…

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

Ivan

comment:18 Changed 12 years ago by anonymous

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:19 Changed 12 years ago by ajpiano

#8238 is a duplicate of this ticket.

comment:20 Changed 12 years ago by Spikeon

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 zwu_ca@…

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 snover

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.

Last edited 12 years ago by snover (previous) (diff)

comment:23 Changed 12 years ago by Spikeon

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 anonymous

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:25 Changed 12 years ago by Rick Waldron

Here is the 1.5.1 schedule:

RC: Feb 18th. Final: Feb 24th.

comment:26 Changed 12 years ago by anonymous

@rwaldron: Thanks for the info :)

comment:27 Changed 12 years ago by ajpiano

#8349 is a duplicate of this ticket.

comment:28 Changed 12 years ago by ajpiano

#8354 is a duplicate of this ticket.

comment:29 Changed 12 years ago by ajpiano

#8357 is a duplicate of this ticket.

comment:30 Changed 12 years ago by ajpiano

#8364 is a duplicate of this ticket.

comment:31 Changed 12 years ago by anonymous

good!

comment:32 Changed 12 years ago by anonymous

still dies not work in IE 9 .8080

comment:33 Changed 12 years ago by qwertypants

Not working on IE9 version 9.0.8112.16421 64bit

comment:34 in reply to:  33 Changed 12 years ago by cymbals

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:35 Changed 12 years ago by anonymous

Still seeing this bug in 1.5 and IE 9.

comment:36 Changed 12 years ago by joaquinrivero

Still seeing this bug in 1.5 and IE 9.

comment:37 Changed 12 years ago by Rick Waldron

Please test with the latest jQuery:

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

comment:38 Changed 12 years ago by anonymous

Still seeing this bug with 1.5.2 and IE9

comment:39 Changed 12 years ago by deCube

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 prashant9792@…

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

comment:41 Changed 12 years ago by anonymous

Still a bug in IE 9.0.8112.16421

comment:42 Changed 12 years ago by Rick Waldron

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 reedlauber

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

comment:44 Changed 12 years ago by anonymous

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 paul

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 Changed 12 years ago by 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.

comment:47 Changed 12 years ago by Rick Waldron

This will fail in IE <9

comment:48 Changed 12 years ago by dj.sidali@…

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 in reply to:  description Changed 12 years ago by anonymous

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 in reply to:  46 Changed 12 years ago by zorba

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 anonymous

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

Note: See TracTickets for help on using tickets.