mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Effects.core: Check Visibility vs 'hide' and 'show' modes, finish immediately if neccessary - Fixes #6715 - Hide and Show try to affect hidden and showing elements
This commit is contained in:
parent
a89ff4098a
commit
d18cd7ed0f
@ -19,6 +19,18 @@ var minDuration = 15,
|
||||
|
||||
module( "effects.core" );
|
||||
|
||||
test( "Immediate Return Conditions", function() {
|
||||
var hidden = $( "div.hidden" ),
|
||||
count = 0;
|
||||
expect( 6 );
|
||||
hidden.hide( "blind", function() {
|
||||
equal( ++count, 1, "Hide on hidden returned immediately" );
|
||||
}).show().show( "blind", function() {
|
||||
equal( ++count, 2, "Show on shown returned immediately" );
|
||||
});
|
||||
equal( ++count, 3, "Both Functions worked properly" );
|
||||
});
|
||||
|
||||
$.each( $.effects.effect, function( effect ) {
|
||||
if ( effect === "transfer" ) {
|
||||
return;
|
||||
|
15
ui/jquery.effects.core.js
vendored
15
ui/jquery.effects.core.js
vendored
@ -556,19 +556,26 @@ $.fn.extend({
|
||||
}
|
||||
|
||||
function run( next ) {
|
||||
var elem = this,
|
||||
complete = args.complete;
|
||||
var elem = $( this ),
|
||||
complete = args.complete,
|
||||
mode = args.mode;
|
||||
|
||||
function done() {
|
||||
if ( $.isFunction( complete ) ) {
|
||||
complete.call( elem );
|
||||
complete.call( elem[0] );
|
||||
}
|
||||
if ( $.isFunction( next ) ) {
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
effectMethod.call( elem, args, done );
|
||||
// if the element is hiddden and mode is hide,
|
||||
// or element is visible and mode is show
|
||||
if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
|
||||
done();
|
||||
} else {
|
||||
effectMethod.call( elem[0], args, done );
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove this check in 2.0, effectMethod will always be true
|
||||
|
Loading…
Reference in New Issue
Block a user