Merge branch 'fix7762' into jquery master. Fixes #7762.
This commit is contained in:
commit
429b078dc7
1 changed files with 26 additions and 43 deletions
69
src/event.js
69
src/event.js
|
@ -63,7 +63,7 @@ jQuery.event = {
|
|||
var eventKey = elem.nodeType ? "events" : "__events__",
|
||||
events = elemData[ eventKey ],
|
||||
eventHandle = elemData.handle;
|
||||
|
||||
|
||||
if ( typeof events === "function" ) {
|
||||
// On plain objects events is a fn that holds the the data
|
||||
// which prevents this data from being JSON serialized
|
||||
|
@ -143,9 +143,9 @@ jQuery.event = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( special.add ) {
|
||||
special.add.call( elem, handleObj );
|
||||
|
||||
if ( special.add ) {
|
||||
special.add.call( elem, handleObj );
|
||||
|
||||
if ( !handleObj.handler.guid ) {
|
||||
handleObj.handler.guid = handler.guid;
|
||||
|
@ -184,7 +184,7 @@ jQuery.event = {
|
|||
if ( !elemData || !events ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( typeof events === "function" ) {
|
||||
elemData = events;
|
||||
events = events.events;
|
||||
|
@ -222,7 +222,7 @@ jQuery.event = {
|
|||
namespaces = type.split(".");
|
||||
type = namespaces.shift();
|
||||
|
||||
namespace = new RegExp("(^|\\.)" +
|
||||
namespace = new RegExp("(^|\\.)" +
|
||||
jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,7 @@ jQuery.event = {
|
|||
isClick = jQuery.nodeName( target, "a" ) && targetType === "click",
|
||||
special = jQuery.event.special[ targetType ] || {};
|
||||
|
||||
if ( (!special._default || special._default.call( elem, event ) === false) &&
|
||||
if ( (!special._default || special._default.call( elem, event ) === false) &&
|
||||
!isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
|
||||
|
||||
try {
|
||||
|
@ -454,7 +454,7 @@ jQuery.event = {
|
|||
event.handler = handleObj.handler;
|
||||
event.data = handleObj.data;
|
||||
event.handleObj = handleObj;
|
||||
|
||||
|
||||
var ret = handleObj.handler.apply( this, args );
|
||||
|
||||
if ( ret !== undefined ) {
|
||||
|
@ -553,7 +553,7 @@ jQuery.event = {
|
|||
add: function( handleObj ) {
|
||||
jQuery.event.add( this,
|
||||
liveConvert( handleObj.origType, handleObj.selector ),
|
||||
jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
|
||||
jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
|
||||
},
|
||||
|
||||
remove: function( handleObj ) {
|
||||
|
@ -583,7 +583,7 @@ jQuery.removeEvent = document.removeEventListener ?
|
|||
if ( elem.removeEventListener ) {
|
||||
elem.removeEventListener( type, handle, false );
|
||||
}
|
||||
} :
|
||||
} :
|
||||
function( elem, type, handle ) {
|
||||
if ( elem.detachEvent ) {
|
||||
elem.detachEvent( "on" + type, handle );
|
||||
|
@ -636,7 +636,7 @@ jQuery.Event.prototype = {
|
|||
if ( !e ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if preventDefault exists run it on the original event
|
||||
if ( e.preventDefault ) {
|
||||
e.preventDefault();
|
||||
|
@ -732,7 +732,7 @@ if ( !jQuery.support.submitBubbles ) {
|
|||
return trigger( "submit", this, arguments );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
|
||||
var elem = e.target,
|
||||
type = elem.type;
|
||||
|
@ -794,7 +794,7 @@ if ( !jQuery.support.changeBubbles ) {
|
|||
if ( e.type !== "focusout" || elem.type !== "radio" ) {
|
||||
jQuery.data( elem, "_change_data", val );
|
||||
}
|
||||
|
||||
|
||||
if ( data === undefined || val === data ) {
|
||||
return;
|
||||
}
|
||||
|
@ -808,7 +808,7 @@ if ( !jQuery.support.changeBubbles ) {
|
|||
|
||||
jQuery.event.special.change = {
|
||||
filters: {
|
||||
focusout: testChange,
|
||||
focusout: testChange,
|
||||
|
||||
beforedeactivate: testChange,
|
||||
|
||||
|
@ -879,15 +879,15 @@ if ( document.addEventListener ) {
|
|||
if ( focusCounts[fix]++ === 0 ) {
|
||||
document.addEventListener( orig, handler, true );
|
||||
}
|
||||
},
|
||||
teardown: function() {
|
||||
},
|
||||
teardown: function() {
|
||||
if ( --focusCounts[fix] === 0 ) {
|
||||
document.removeEventListener( orig, handler, true );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function handler( e ) {
|
||||
function handler( e ) {
|
||||
e = jQuery.event.fix( e );
|
||||
e.type = fix;
|
||||
return jQuery.event.trigger( e, null, e.target );
|
||||
|
@ -904,7 +904,7 @@ jQuery.each(["bind", "one"], function( i, name ) {
|
|||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
if ( jQuery.isFunction( data ) || data === false ) {
|
||||
fn = data;
|
||||
data = undefined;
|
||||
|
@ -944,20 +944,20 @@ jQuery.fn.extend({
|
|||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
||||
delegate: function( selector, types, data, fn ) {
|
||||
return this.live( types, data, fn, selector );
|
||||
},
|
||||
|
||||
|
||||
undelegate: function( selector, types, fn ) {
|
||||
if ( arguments.length === 0 ) {
|
||||
return this.unbind( "live" );
|
||||
|
||||
|
||||
} else {
|
||||
return this.die( types, null, fn, selector );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
trigger: function( type, data ) {
|
||||
return this.each(function() {
|
||||
jQuery.event.trigger( type, data, this );
|
||||
|
@ -1014,12 +1014,12 @@ jQuery.each(["live", "die"], function( i, name ) {
|
|||
var type, i = 0, match, namespaces, preType,
|
||||
selector = origSelector || this.selector,
|
||||
context = origSelector ? this : jQuery( this.context );
|
||||
|
||||
|
||||
if ( typeof types === "object" && !types.preventDefault ) {
|
||||
for ( var key in types ) {
|
||||
context[ name ]( key, data, types[key], selector );
|
||||
}
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -1066,7 +1066,7 @@ jQuery.each(["live", "die"], function( i, name ) {
|
|||
context.unbind( "live." + liveConvert( type, selector ), fn );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return this;
|
||||
};
|
||||
});
|
||||
|
@ -1085,7 +1085,7 @@ function liveHandler( event ) {
|
|||
if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( event.namespace ) {
|
||||
namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
|
||||
}
|
||||
|
@ -1183,21 +1183,4 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
|
|||
}
|
||||
});
|
||||
|
||||
// Prevent memory leaks in IE
|
||||
// Window isn't included so as not to unbind existing unload events
|
||||
// More info:
|
||||
// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
|
||||
if ( window.attachEvent && !window.addEventListener ) {
|
||||
jQuery(window).bind("unload", function() {
|
||||
for ( var id in jQuery.cache ) {
|
||||
if ( jQuery.cache[ id ].handle ) {
|
||||
// Try/Catch is to handle iframes being unloaded, see #4280
|
||||
try {
|
||||
jQuery.event.remove( jQuery.cache[ id ].handle.elem );
|
||||
} catch(e) {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
})( jQuery );
|
||||
|
|
Loading…
Reference in a new issue