Skip to content

Commit

Permalink
Make sure that we don't try to trigger non-existant native events on …
Browse files Browse the repository at this point in the history
…applets, embed, objects, etc. as it'll cause an exception with Java applets. Fixes #2414.
  • Loading branch information
jeresig committed Dec 9, 2009
1 parent 1052792 commit 3ec2f1a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/event.js
Expand Up @@ -253,8 +253,10 @@ jQuery.event = {

var nativeFn, nativeHandler;
try {
nativeFn = elem[ type ];
nativeHandler = elem[ "on" + type ];
if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
nativeFn = elem[ type ];
nativeHandler = elem[ "on" + type ];
}
// prevent IE from throwing an error for some elements with some event types, see #3533
} catch (e) {}

Expand Down

3 comments on commit 3ec2f1a

@pseudosavant
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could/can this functionality easily be disabled at runtime? I found out about this aspect of jQuery when I was trying to use it with events on non-Java plugins. It would be nice if there was a way to override this functionality without having to host/build my own copy of jQuery that doesn't have this behavior.

@jeresig
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are enabled for Flash plugins in 1.4.3. If you want to allow it to run anyway then just override jQuery.noData with the appropriate set of elements that you do/don't want data to be attached to.

@pseudosavant
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tip and quick response! I'll try that out.

Please sign in to comment.