aboutsummaryrefslogtreecommitdiffstats
path: root/tests/jquery.simulate.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-11-01 16:35:49 -0400
committerScott González <scott.gonzalez@gmail.com>2012-01-12 09:06:07 -0500
commitaa9ca2ba84cbc78f77e47eeef91747cf22b14824 (patch)
tree1a1893847ca4ffe0d65f4920cf6c2db960d9d740 /tests/jquery.simulate.js
parent069c6454032424ed82a3f6024248be83a4be565b (diff)
downloadjquery-ui-aa9ca2ba84cbc78f77e47eeef91747cf22b14824.tar.gz
jquery-ui-aa9ca2ba84cbc78f77e47eeef91747cf22b14824.zip
Tests (Simulate): Make the blur event async to deal with IE's native blur being async.
(cherry picked from commit 183d6a00df531b13c638944796b5bc52ca19ecb4)
Diffstat (limited to 'tests/jquery.simulate.js')
-rw-r--r--tests/jquery.simulate.js27
1 files changed, 16 insertions, 11 deletions
diff --git a/tests/jquery.simulate.js b/tests/jquery.simulate.js
index c1d28f982..adc340049 100644
--- a/tests/jquery.simulate.js
+++ b/tests/jquery.simulate.js
@@ -194,18 +194,23 @@ $.extend( $.simulate.prototype, {
element.bind( "blur", trigger );
element[ 0 ].blur();
- // Some versions of IE don't actually .blur() on an element - so we focus the body
- if ( element[ 0 ].ownerDocument.activeElement === element[ 0 ] ) {
- element[ 0 ].ownerDocument.body.focus();
- }
+ // blur events are async in IE
+ setTimeout(function() {
+ // IE won't let the blur occur if the window is inactive
+ if ( element[ 0 ].ownerDocument.activeElement === element[ 0 ] ) {
+ element[ 0 ].ownerDocument.body.focus();
+ }
- if ( !triggered ) {
- focusoutEvent = $.Event( "focusout" );
- focusoutEvent.preventDefault();
- element.trigger( focusoutEvent );
- element.triggerHandler( "blur" );
- }
- element.unbind( "blur", trigger );
+ // Firefox won't trigger events if the window is inactive
+ // IE doesn't trigger events if we had to manually focus the body
+ if ( !triggered ) {
+ focusoutEvent = $.Event( "focusout" );
+ focusoutEvent.preventDefault();
+ element.trigger( focusoutEvent );
+ element.triggerHandler( "blur" );
+ }
+ element.unbind( "blur", trigger );
+ }, 1 );
}
});