aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2012-03-04 21:11:50 -0500
committerDave Methvin <dave.methvin@gmail.com>2012-03-06 19:56:17 -0500
commit92a92be10f2c6eecc93e0def9001a2ef2852fde1 (patch)
tree0efe3572f9d5a034180caf4be48f7670b4401a46 /src/event.js
parent619f0d908a4227d4fd49971d7f9a5290eaffd72d (diff)
downloadjquery-92a92be10f2c6eecc93e0def9001a2ef2852fde1.tar.gz
jquery-92a92be10f2c6eecc93e0def9001a2ef2852fde1.zip
Fix #11049. Let bubbling submit be cancellable in oldIE.
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/event.js b/src/event.js
index 6bb4fa816..621464fdd 100644
--- a/src/event.js
+++ b/src/event.js
@@ -391,6 +391,7 @@ jQuery.event = {
delegateCount = handlers.delegateCount,
args = [].slice.call( arguments, 0 ),
run_all = !event.exclusive && !event.namespace,
+ special = jQuery.event.special[ event.type ] || {},
handlerQueue = [],
i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related;
@@ -398,6 +399,11 @@ jQuery.event = {
args[0] = event;
event.delegateTarget = this;
+ // Call the preDispatch hook for the mapped type, and let it bail if desired
+ if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
+ return;
+ }
+
// Determine handlers that should run if there are delegated events
// Avoid non-left-click bubbling in Firefox (#3861)
if ( delegateCount && !(event.button && event.type === "click") ) {
@@ -407,7 +413,7 @@ jQuery.event = {
jqcur.context = this.ownerDocument || this;
for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
-
+
// Don't process events on disabled elements (#6911, #8165)
if ( cur.disabled !== true ) {
selMatch = {};
@@ -467,6 +473,11 @@ jQuery.event = {
}
}
+ // Call the postDispatch hook for the mapped type
+ if ( special.postDispatch ) {
+ special.postDispatch.call( this, event );
+ }
+
return event.result;
},
@@ -758,16 +769,23 @@ if ( !jQuery.support.submitBubbles ) {
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
if ( form && !form._submit_attached ) {
jQuery.event.add( form, "submit._submit", function( event ) {
- // If form was submitted by the user, bubble the event up the tree
- if ( this.parentNode && !event.isTrigger ) {
- jQuery.event.simulate( "submit", this.parentNode, event, true );
- }
+ event._submit_bubble = true;
});
form._submit_attached = true;
}
});
// return undefined since we don't need an event listener
},
+
+ postDispatch: function( event ) {
+ // If form was submitted by the user, bubble the event up the tree
+ if ( event._submit_bubble ) {
+ delete event._submit_bubble;
+ if ( this.parentNode && !event.isTrigger ) {
+ jQuery.event.simulate( "submit", this.parentNode, event, true );
+ }
+ }
+ },
teardown: function() {
// Only need this for delegated form submit events