Skip to content

Commit

Permalink
Merge branch 'fix7762' into jquery master. Fixes #7762.
Browse files Browse the repository at this point in the history
  • Loading branch information
csnover committed Dec 30, 2010
2 parents 9029dc0 + 37d297c commit 429b078
Showing 1 changed file with 26 additions and 43 deletions.
69 changes: 26 additions & 43 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -184,7 +184,7 @@ jQuery.event = {
if ( !elemData || !events ) {
return;
}

if ( typeof events === "function" ) {
elemData = events;
events = events.events;
Expand Down Expand Up @@ -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("\\.(?:.*\\.)?") + "(\\.|$)");
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -636,7 +636,7 @@ jQuery.Event.prototype = {
if ( !e ) {
return;
}

// if preventDefault exists run it on the original event
if ( e.preventDefault ) {
e.preventDefault();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -808,7 +808,7 @@ if ( !jQuery.support.changeBubbles ) {

jQuery.event.special.change = {
filters: {
focusout: testChange,
focusout: testChange,

beforedeactivate: testChange,

Expand Down Expand Up @@ -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 );
Expand All @@ -904,7 +904,7 @@ jQuery.each(["bind", "one"], function( i, name ) {
}
return this;
}

if ( jQuery.isFunction( data ) || data === false ) {
fn = data;
data = undefined;
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -1066,7 +1066,7 @@ jQuery.each(["live", "die"], function( i, name ) {
context.unbind( "live." + liveConvert( type, selector ), fn );
}
}

return this;
};
});
Expand All @@ -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("\\.(?:.*\\.)?") + "(\\.|$)");
}
Expand Down Expand Up @@ -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 );

0 comments on commit 429b078

Please sign in to comment.