Bug Tracker

Opened 10 years ago

Closed 9 years ago

Last modified 7 years ago

#5027 closed bug (duplicate)

jquery failure when using prototype.js - getElementsByClassName, IE

Reported by: rantav Owned by: john
Priority: major Milestone: 1.4
Component: selector Version: 1.3.2
Keywords: getElementsByClassName Cc: rantav@…
Blocked by: Blocking:

Description

In my widget I use jquery (thanks, it's awesome!) along with jquery-tools. The widget is embedded in other sites, so I use compatibility mode:

var obJQuery = jQuery.noConflict(true);

So far so good. Here's the bug though: In one of the sites where my widget is installed prototype.js is used. In this site, on IE6/7/8 I get a javascript error in my widget stemming from the fact (to my understanding) that prototype defines getElementsByClassName on the document object, but not for all other dom elements. (prototype Version 1.6.0.3).

jquery assumes that if the method getElementsByClassName exists on the document element it exists on all other dom elements as well and so in selector.js:749 we get an error.

I have to say I'm relatively new to jquery so the usual disclaimer - if I'm missing something, sorry...

Not sure about the fix, but it may be this:

if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){

var div = document.createElement("div");

div.innerHTML = "<div class='test e'></div><div class='test'></div>";

if (!div.getElementsByClassName) { this is the fix. check div.getElementsByClassName

return;

}

Change History (3)

comment:1 Changed 10 years ago by rantav

comment:2 Changed 9 years ago by addyosmani

Resolution: duplicate
Status: newclosed

comment:3 Changed 9 years ago by addyosmani

Duplicate of #4365.

Note: See TracTickets for help on using tickets.