davioliveiraweb / spriteme

Automatically exported from code.google.com/p/spriteme
0 stars 0 forks source link

fails on Safari, Mac, news.cnet.com #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Works on most sites but fails on http://news.cnet.com/ in Safari (4.0.3) on
Mac.

Original issue reported on code.google.com by stevesou...@gmail.com on 2 Sep 2009 at 10:56

GoogleCodeExporter commented 9 years ago

Original comment by stevesou...@gmail.com on 10 Sep 2009 at 3:55

GoogleCodeExporter commented 9 years ago

Original comment by stevesou...@gmail.com on 22 Sep 2009 at 5:42

GoogleCodeExporter commented 9 years ago
CNet uses MooTools which redefines getElementsByClassName which causes a 
conflict
with Sizzle in jQuery (wow, that's a mouthful). I entered a bug:
http://dev.jquery.com/ticket/5284 but patched a workaround for now.

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(){ 

Original comment by stevesou...@gmail.com on 22 Sep 2009 at 8:47