From 4ecb1b7e57e0bfef9e484c3e14a57289a19e6f61 Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Wed, 11 Nov 2015 19:43:24 +0300 Subject: [PATCH] Revert "Event: remove deprecated event aliases" This reverts commit 0705be475092aede1eddae01319ec931fb9c65fc. --- src/event/alias.js | 4 ++-- test/unit/event.js | 52 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/event/alias.js b/src/event/alias.js index b1b8f701f..161c8935e 100644 --- a/src/event/alias.js +++ b/src/event/alias.js @@ -5,9 +5,9 @@ define( [ "./trigger" ], function( jQuery ) { -jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + +jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + - "change select submit keydown keypress keyup contextmenu" ).split( " " ), + "change select submit keydown keypress keyup error contextmenu" ).split( " " ), function( i, name ) { // Handle event binding diff --git a/test/unit/event.js b/test/unit/event.js index 4a5611be8..cdebbb4e7 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -900,7 +900,57 @@ QUnit.test( "mouseenter, mouseleave don't catch exceptions", function( assert ) } } ); -QUnit.test( "trigger() bubbling", function( assert ) { +if ( jQuery.fn.click ) { + + QUnit.test("trigger() shortcuts", function( assert ) { + assert.expect( 6 ); + + var counter, clickCounter, + elem = jQuery("
  • Change location
  • ").prependTo("#firstUL"); + elem.find("a").on("click", function() { + var close = jQuery("spanx", this); // same with jQuery(this).find("span"); + assert.equal( close.length, 0, "Context element does not exist, length must be zero" ); + assert.ok( !close[0], "Context element does not exist, direct access to element must return undefined" ); + return false; + }).click(); + + // manually clean up detached elements + elem.remove(); + + jQuery("#check1").click(function() { + assert.ok( true, "click event handler for checkbox gets fired twice, see #815" ); + }).click(); + + counter = 0; + jQuery("#firstp")[0].onclick = function() { + counter++; + }; + jQuery("#firstp").click(); + assert.equal( counter, 1, "Check that click, triggers onclick event handler also" ); + + clickCounter = 0; + jQuery("#simon1")[0].onclick = function() { + clickCounter++; + }; + jQuery("#simon1").click(); + assert.equal( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" ); + + elem = jQuery("").load(function(){ + assert.ok( true, "Trigger the load event, using the shortcut .load() (#2819)"); + }).load(); + + // manually clean up detached elements + elem.remove(); + + // test that special handlers do not blow up with VML elements (#7071) + jQuery("").appendTo("head"); + jQuery(" ").appendTo("#form"); + jQuery("#oval").click().keydown(); + }); + +} + +QUnit.test("trigger() bubbling", function( assert ) { assert.expect( 18 ); var win = 0, doc = 0, html = 0, body = 0, main = 0, ap = 0; -- 2.39.5