Bug Tracker

Modify

Ticket #8052 (closed bug: fixed)

Opened 3 years ago

Last modified 2 years ago

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:
Blocking: Blocked by:

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

comment:1 Changed 3 years ago by addyosmani

  • Owner set to thiessenp@…
  • Priority changed from undecided to low
  • Status changed from new to pending

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.

Last edited 3 years ago by addyosmani (previous) (diff)

comment:2 Changed 3 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 3 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 3 years ago by jitter (previous) (diff)

comment:4 Changed 3 years ago by jitter

  • Owner changed from thiessenp@… to snover
  • Priority changed from low to high
  • Status changed from pending to assigned
  • Component changed from unfiled to manipulation
  • Milestone changed from 1.next to 1.5.1

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

comment:6 Changed 3 years ago by rwaldron

#8080 is a duplicate of this ticket.

comment:7 Changed 3 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 3 years ago by ajpiano

#8133 is a duplicate of this ticket.

comment:9 Changed 3 years ago by jitter

#8139 is a duplicate of this ticket.

comment:10 Changed 3 years ago by jitter

  • Priority changed from high to blocker

comment:11 Changed 3 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 3 years ago by jitter

#8153 is a duplicate of this ticket.

comment:13 Changed 3 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 3 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 3 years ago by snover (previous) (diff)

comment:15 Changed 3 years ago by jitter

#8183 is a duplicate of this ticket.

comment:16 Changed 3 years ago by Colin Snover

  • Status changed from assigned to closed
  • Resolution set to fixed

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

Changeset: 534dbd660eaefbbc5827b1b61ba384e768562086

comment:17 Changed 3 years ago by Info@…

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

Ivan

comment:18 Changed 3 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 3 years ago by ajpiano

#8238 is a duplicate of this ticket.

comment:20 Changed 3 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 3 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 3 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 3 years ago by snover (previous) (diff)

comment:23 Changed 3 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 3 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 3 years ago by rwaldron

Here is the 1.5.1 schedule:

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

comment:26 Changed 3 years ago by anonymous

@rwaldron: Thanks for the info :)

comment:27 Changed 3 years ago by ajpiano

#8349 is a duplicate of this ticket.

comment:28 Changed 3 years ago by ajpiano

#8354 is a duplicate of this ticket.

comment:29 Changed 3 years ago by ajpiano

#8357 is a duplicate of this ticket.

comment:30 Changed 3 years ago by ajpiano

#8364 is a duplicate of this ticket.

comment:31 Changed 3 years ago by anonymous

good!

comment:32 Changed 3 years ago by anonymous

still dies not work in IE 9 .8080

comment:33 follow-up: ↓ 34 Changed 3 years ago by qwertypants

Not working on IE9 version 9.0.8112.16421 64bit

comment:34 in reply to: ↑ 33 Changed 3 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 3 years ago by anonymous

Still seeing this bug in 1.5 and IE 9.

comment:36 Changed 3 years ago by joaquinrivero

Still seeing this bug in 1.5 and IE 9.

comment:37 Changed 3 years ago by rwaldron

Please test with the latest jQuery:

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

comment:38 Changed 3 years ago by anonymous

Still seeing this bug with 1.5.2 and IE9

comment:39 Changed 3 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 3 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 3 years ago by anonymous

Still a bug in IE 9.0.8112.16421

comment:42 Changed 3 years ago by rwaldron

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 3 years ago by reedlauber

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

comment:44 Changed 3 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 3 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 follow-up: ↓ 50 Changed 3 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 3 years ago by rwaldron

This will fail in IE <9

comment:48 Changed 3 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 3 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 3 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 3 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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.