Bug fix with how global event triggers are handled.
This commit is contained in:
parent
64179692a0
commit
0a9c569839
1 changed files with 14 additions and 14 deletions
28
jquery/jquery.js
vendored
28
jquery/jquery.js
vendored
|
@ -811,11 +811,11 @@ jQuery.event = {
|
||||||
handlers[0] = element["on" + type];
|
handlers[0] = element["on" + type];
|
||||||
}
|
}
|
||||||
handlers[handler.guid] = handler;
|
handlers[handler.guid] = handler;
|
||||||
element["on" + type] = jQuery.event.handle;
|
element["on" + type] = this.handle;
|
||||||
|
|
||||||
var g = jQuery.event.global;
|
if (!this.global[type])
|
||||||
if (!g[type]) g[type] = [];
|
this.global[type] = [];
|
||||||
g[type].push( element );
|
this.global[type].push( element );
|
||||||
},
|
},
|
||||||
|
|
||||||
guid: 1,
|
guid: 1,
|
||||||
|
@ -832,27 +832,27 @@ jQuery.event = {
|
||||||
delete element.events[type][i];
|
delete element.events[type][i];
|
||||||
else
|
else
|
||||||
for ( var j in element.events )
|
for ( var j in element.events )
|
||||||
jQuery.event.remove( element, j );
|
this.remove( element, j );
|
||||||
},
|
},
|
||||||
|
|
||||||
trigger: function(type,data,element) {
|
trigger: function(type,data,element) {
|
||||||
// Touch up the incoming data
|
// Touch up the incoming data
|
||||||
data = data || [];
|
data = data || [];
|
||||||
|
|
||||||
|
// Handle a global trigger
|
||||||
|
if ( !element ) {
|
||||||
|
var g = this.global[type];
|
||||||
|
if ( g )
|
||||||
|
for ( var i = 0; i < g.length; i++ )
|
||||||
|
this.trigger( type, data, g[i] );
|
||||||
|
|
||||||
// Handle triggering a single element
|
// Handle triggering a single element
|
||||||
if ( element && element["on" + type] ) {
|
} else if ( element["on" + type] ) {
|
||||||
// Pass along a fake event
|
// Pass along a fake event
|
||||||
data.shift( jQuery.event.fix({ type: type, target: element }) );
|
data.unshift( this.fix({ type: type, target: element }) );
|
||||||
|
|
||||||
// Trigger the event
|
// Trigger the event
|
||||||
element["on" + type].apply( element, data );
|
element["on" + type].apply( element, data );
|
||||||
|
|
||||||
// Handle a global trigger
|
|
||||||
} else if ( !element ) {
|
|
||||||
var g = jQuery.event.global[type];
|
|
||||||
if ( g )
|
|
||||||
for ( var i = 0; i < g.length; i++ )
|
|
||||||
jQuery.event.trigger( type, data, g[i] );
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue