mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Tests (Simulate): Make the blur event async to deal with IE's native blur being async.
(cherry picked from commit 183d6a00df
)
This commit is contained in:
parent
069c645403
commit
aa9ca2ba84
@ -194,18 +194,23 @@ $.extend( $.simulate.prototype, {
|
|||||||
element.bind( "blur", trigger );
|
element.bind( "blur", trigger );
|
||||||
element[ 0 ].blur();
|
element[ 0 ].blur();
|
||||||
|
|
||||||
// Some versions of IE don't actually .blur() on an element - so we focus the body
|
// blur events are async in IE
|
||||||
if ( element[ 0 ].ownerDocument.activeElement === element[ 0 ] ) {
|
setTimeout(function() {
|
||||||
element[ 0 ].ownerDocument.body.focus();
|
// 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 ) {
|
// Firefox won't trigger events if the window is inactive
|
||||||
focusoutEvent = $.Event( "focusout" );
|
// IE doesn't trigger events if we had to manually focus the body
|
||||||
focusoutEvent.preventDefault();
|
if ( !triggered ) {
|
||||||
element.trigger( focusoutEvent );
|
focusoutEvent = $.Event( "focusout" );
|
||||||
element.triggerHandler( "blur" );
|
focusoutEvent.preventDefault();
|
||||||
}
|
element.trigger( focusoutEvent );
|
||||||
element.unbind( "blur", trigger );
|
element.triggerHandler( "blur" );
|
||||||
|
}
|
||||||
|
element.unbind( "blur", trigger );
|
||||||
|
}, 1 );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user