jquery event: closes #4033. e.currentTarget wasn't being enforced for native events (IE doesn't have it)
This commit is contained in:
parent
72cf42bcbd
commit
0a1b0db347
|
@ -240,7 +240,8 @@ jQuery.event = {
|
||||||
var all, handlers;
|
var all, handlers;
|
||||||
|
|
||||||
event = arguments[0] = jQuery.event.fix( event || window.event );
|
event = arguments[0] = jQuery.event.fix( event || window.event );
|
||||||
|
event.currentTarget = this;
|
||||||
|
|
||||||
// Namespaced event handlers
|
// Namespaced event handlers
|
||||||
var namespaces = event.type.split(".");
|
var namespaces = event.type.split(".");
|
||||||
event.type = namespaces.shift();
|
event.type = namespaces.shift();
|
||||||
|
|
|
@ -417,6 +417,20 @@ test("trigger(eventObject, [data], [fn])", function() {
|
||||||
$parent.unbind().remove();
|
$parent.unbind().remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("jQuery.Event.currentTarget", function(){
|
||||||
|
expect(2);
|
||||||
|
|
||||||
|
var counter = 0,
|
||||||
|
$elem = jQuery('<button>a</button>').click(function(e){
|
||||||
|
equals( e.currentTarget, this, "Check currentTarget on "+(counter++?"native":"fake") +" event" );
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fake event
|
||||||
|
$elem.trigger('click');
|
||||||
|
// Native event (#4033)
|
||||||
|
triggerEvent( $elem[0], 'click' );
|
||||||
|
});
|
||||||
|
|
||||||
test("toggle(Function, Function, ...)", function() {
|
test("toggle(Function, Function, ...)", function() {
|
||||||
expect(11);
|
expect(11);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue