A lot of people think jQuery is the greatest thing since sliced bread because it doesn’t extend the DOM like Prototype, but it actually does. What’s worse—its extension process is actually designed to fail in certain cases while the rest of the code pretends to know nothing about them.
I’d like to introduce you to Exhibit A: line 995 of jquery-1.4.2.js
// The following elements throw uncatchable exceptions if you
// attempt to add expando properties to them.
noData: {
"embed": true,
"object": true,
"applet": true
}
As the comments state, this is a list of DOM element types which jQuery believes it cannot extend and will avoid trying. Why on earth would anyone ever care? Well, just try to fadeIn an SVG object and watch your whole script die mysteriously.
When jQuery wants to animate something, it creates an animation queue and associates this queue with the DOM object through the use of its expando-creating data method. This method is designed to give up immediately when encountering one of these blacklisted element types, but the queue method behaves as though failure is unthinkable when it accesses this nonexistent data outside of a try block. Thus, you get a silent, inexplicable death, and no animation to speak of.
Now there may be some browsers where attempting to extend object elements really does result in some kind of uncatchable exception
as the comments would lead us to believe, but Safari and Firefox aren’t among them. Since they’re the only ones anyone using SVG is likely to care about, blacklisting them in this way is just plain dumb.
Luckily, the workaround is easy. While you’re waiting for a future release to incorporate better exception handling, just throw this somewhere before you need to animate your object, and it’ll work as expected:
jQuery.noData.object = false;
I haven’t tried it on an applet, but nobody should be using those ungodly things anymore, anyway.