Skip to main content

Bug Tracker

Side navigation

#5027 closed bug (duplicate)

Opened August 09, 2009 11:16AM UTC

Closed October 28, 2010 04:49AM UTC

Last modified March 13, 2012 06:28PM UTC

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

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

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



Attachments (0)
Change History (3)

Changed August 09, 2009 07:39PM UTC by rantav comment:1

Changed October 28, 2010 04:49AM UTC by addyosmani comment:2

resolution: → duplicate
status: newclosed

Changed October 28, 2010 04:49AM UTC by addyosmani comment:3

Duplicate of #4365.