Bug Tracker

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#5284 closed bug (duplicate)

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

Change History (3)

comment:1 Changed 10 years ago by dmethvin

Component: unfilledselector
Keywords: mootools conflict added
Owner: set to 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.

comment:2 Changed 9 years ago by Rick Waldron

Resolution: duplicate
Status: newclosed

comment:3 Changed 9 years ago by Rick Waldron

Duplicate of #4365.

Note: See TracTickets for help on using tickets.