aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/event.js
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2013-02-01 21:20:15 -0500
committerDave Methvin <dave.methvin@gmail.com>2013-04-03 20:25:50 -0400
commit65a6648932d197629fc454f37ce3157a51c2921a (patch)
treefa73be02656c9a4350bb71f7b495121989c676df /test/unit/event.js
parentb6dd1c67a63d19ff4b22b893f4d47f80f0d47fd9 (diff)
downloadjquery-65a6648932d197629fc454f37ce3157a51c2921a.tar.gz
jquery-65a6648932d197629fc454f37ce3157a51c2921a.zip
Ref #13353: capture onlyHandlers in jQuery.Event.isTrigger. Close gh-1183.
Diffstat (limited to 'test/unit/event.js')
-rw-r--r--test/unit/event.js49
1 files changed, 35 insertions, 14 deletions
diff --git a/test/unit/event.js b/test/unit/event.js
index dab120d0c..070f75a0b 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -1487,21 +1487,42 @@ test("jQuery.Event( type, props )", function() {
});
-test("jQuery.Event.currentTarget", function(){
- expect(2);
+test("jQuery.Event properties", function(){
+ expect(12);
- jQuery("<div><p><button>shiny</button></p></div>")
- .on( "click", "p", function( e ){
- equal( e.currentTarget, this, "Check delegated currentTarget on event" );
- })
- .find( "button" )
- .on( "click", function( e ){
- equal( e.currentTarget, this, "Check currentTarget on event" );
- })
- .trigger("click")
- .off( "click" )
- .end()
- .off( "click" );
+ var handler,
+ $structure = jQuery("<div id='ancestor'><p id='delegate'><span id='target'>shiny</span></p></div>"),
+ $target = $structure.find("#target");
+
+ handler = function( e ) {
+ strictEqual( e.currentTarget, this, "currentTarget at " + this.id );
+ equal( e.isTrigger, 3, "trigger at " + this.id );
+ };
+ $structure.one( "click", handler );
+ $structure.one( "click", "p", handler );
+ $target.one( "click", handler );
+ $target[0].onclick = function( e ) {
+ strictEqual( e.currentTarget, this, "currentTarget at target (native handler)" );
+ equal( e.isTrigger, 3, "trigger at target (native handler)" );
+ };
+ $target.trigger("click");
+
+ $target.one( "click", function( e ) {
+ equal( e.isTrigger, 2, "triggerHandler at target" );
+ });
+ $target[0].onclick = function( e ) {
+ equal( e.isTrigger, 2, "triggerHandler at target (native handler)" );
+ };
+ $target.triggerHandler("click");
+
+ handler = function( e ) {
+ strictEqual( e.isTrigger, undefined, "native event at " + this.id );
+ };
+ $target.one( "click", handler );
+ $target[0].onclick = function( e ) {
+ strictEqual( e.isTrigger, undefined, "native event at target (native handler)" );
+ };
+ fireNative( $target[0], "click" );
});
test(".delegate()/.undelegate()", function() {