Retooled the native triggering code, simplifying it.
This commit is contained in:
parent
25b0ba9f96
commit
8d1efee316
12
src/event.js
12
src/event.js
|
@ -257,18 +257,20 @@ jQuery.event = {
|
||||||
nativeHandler = elem[ "on" + type ];
|
nativeHandler = elem[ "on" + type ];
|
||||||
// prevent IE from throwing an error for some elements with some event types, see #3533
|
// prevent IE from throwing an error for some elements with some event types, see #3533
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
// Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
|
|
||||||
if ( (!nativeFn || (jQuery.nodeName(elem, 'a') && type === "click")) && nativeHandler && nativeHandler.apply( elem, data ) === false ) {
|
var isClick = jQuery.nodeName(elem, "a") && type === "click";
|
||||||
event.result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trigger the native events (except for clicks on links)
|
// Trigger the native events (except for clicks on links)
|
||||||
if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type === "click") ) {
|
if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !isClick ) {
|
||||||
this.triggered = true;
|
this.triggered = true;
|
||||||
try {
|
try {
|
||||||
nativeFn();
|
nativeFn();
|
||||||
// prevent IE from throwing an error for some hidden elements
|
// prevent IE from throwing an error for some hidden elements
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
|
// Handle triggering native .onfoo handlers
|
||||||
|
} else if ( nativeHandler && nativeHandler.apply( elem, data ) === false ) {
|
||||||
|
event.result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.triggered = false;
|
this.triggered = false;
|
||||||
|
|
Loading…
Reference in a new issue