diff options
author | Scott González <scott.gonzalez@gmail.com> | 2016-04-12 15:10:22 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2016-04-13 11:08:21 -0400 |
commit | 57f801f1de95ce3731c443d35886fbcda989f3a0 (patch) | |
tree | 9ccec9524e20900af723e36f0933b9b529a6bd24 /tests | |
parent | c19fc10e8493007af4617597f0afea5f24860955 (diff) | |
download | jquery-ui-57f801f1de95ce3731c443d35886fbcda989f3a0.tar.gz jquery-ui-57f801f1de95ce3731c443d35886fbcda989f3a0.zip |
Menu: Don't reset active element until after triggering `blur` event
This ensures that `ui.item` actually exists in the `blur` event.
Fixes #14945
Closes gh-1696
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/menu/events.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/unit/menu/events.js b/tests/unit/menu/events.js index 1500c3478..4d2af394f 100644 --- a/tests/unit/menu/events.js +++ b/tests/unit/menu/events.js @@ -48,20 +48,22 @@ test( "handle click on custom item menu", function() { } ); asyncTest( "handle blur", function() { - expect( 1 ); + expect( 2 ); var blurHandled = false, + index = 1, element = $( "#menu1" ).menu( { - blur: function( event ) { + blur: function( event, ui ) { // Ignore duplicate blur event fired by IE if ( !blurHandled ) { blurHandled = true; equal( event.type, "menublur", "blur event.type is 'menublur'" ); + strictEqual( ui.item[ 0 ], element.children()[ index ], "ui.item" ); } } } ); - click( element, "1" ); + click( element, index ); setTimeout( function() { element.trigger( "blur" ); setTimeout( function() { @@ -71,20 +73,22 @@ asyncTest( "handle blur", function() { } ); asyncTest( "handle blur via click outside", function() { - expect( 1 ); + expect( 2 ); var blurHandled = false, + index = 1, element = $( "#menu1" ).menu( { - blur: function( event ) { + blur: function( event, ui ) { // Ignore duplicate blur event fired by IE if ( !blurHandled ) { blurHandled = true; equal( event.type, "menublur", "blur event.type is 'menublur'" ); + strictEqual( ui.item[ 0 ], element.children()[ index ], "ui.item" ); } } } ); - click( element, "1" ); + click( element, index ); setTimeout( function() { $( "<a>", { id: "remove" } ).appendTo( "body" ).trigger( "click" ); setTimeout( function() { |