Skip to main content

Bug Tracker

Side navigation

#5284 closed bug (duplicate)

Opened September 22, 2009 08:43PM UTC

Closed November 08, 2010 09:35PM UTC

Last modified November 08, 2010 09:35PM UTC

mootools conflict with getElementsByClassName

Reported by: souders Owned by: john
Priority: minor Milestone: 1.4
Component: selector Version: 1.3.2
Keywords: mootools conflict Cc: jquery@souders.org
Blocked by: Blocking:
Description

SpriteMe (http://spriteme.org/) is a bookmarklet that uses jquery-1.3.2.js. A user reported a bug running SpriteMe on http://news.cnet.com/ in Safari on the Mac. The issue results from this code in jquery-1.3.2.js (from Sizzle):

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

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

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

Opera can't find a second classname (in 9.6)

if ( div.getElementsByClassName("e").length === 0 )

return;

Safari caches class attributes, doesn't catch changes (in 3.2)

div.lastChild.className = "e";

if ( div.getElementsByClassName("e").length === 1 )

The error occurs when the last line is executed:

TypeError: Result of expression '$.element' [undefined] is not a function. i.i.com.com/cnwk.1d/html/rb/js/tron/oreo.moo.rb.combined.js:6

CNet uses mootools which redefines getElementsByClassName, and this causes the error. I can avoid the error by testing that getElementsByClassName is a native method:

if ( document.getElementsByClassName &&

-1!=document.getElementsByClassName.toString().indexOf("native code") &&

document.documentElement.getElementsByClassName ) (function(){

Is this a suitable fix? Should I be submitting this to Dojo?

Attachments (0)
Change History (3)

Changed September 24, 2009 01:51AM UTC by dmethvin comment:1

component: unfilledselector
keywords: → mootools conflict
owner: → john
priority: majorminor

This was discussed a while back:

http://groups.google.com/group/jquery-en/browse_thread/thread/6c78c0bea37f6f70

It sounds like the jQuery cautionary fix described there isn't working, I wonder if mootools is replacing the native implementation. It would be worth reporting it there and seeing if it's been fixed.

Changed November 08, 2010 09:35PM UTC by rwaldron comment:2

resolution: → duplicate
status: newclosed

Changed November 08, 2010 09:35PM UTC by rwaldron comment:3

Duplicate of #4365.