Skip to content

Commit d18cd7e

Browse files
committed
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
1 parent a89ff40 commit d18cd7e

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

tests/unit/effects/effects_core.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ var minDuration = 15,
1919

2020
module( "effects.core" );
2121

22+
test( "Immediate Return Conditions", function() {
23+
var hidden = $( "div.hidden" ),
24+
count = 0;
25+
expect( 6 );
26+
hidden.hide( "blind", function() {
27+
equal( ++count, 1, "Hide on hidden returned immediately" );
28+
}).show().show( "blind", function() {
29+
equal( ++count, 2, "Show on shown returned immediately" );
30+
});
31+
equal( ++count, 3, "Both Functions worked properly" );
32+
});
33+
2234
$.each( $.effects.effect, function( effect ) {
2335
if ( effect === "transfer" ) {
2436
return;

ui/jquery.effects.core.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,19 +556,26 @@ $.fn.extend({
556556
}
557557

558558
function run( next ) {
559-
var elem = this,
560-
complete = args.complete;
559+
var elem = $( this ),
560+
complete = args.complete,
561+
mode = args.mode;
561562

562563
function done() {
563564
if ( $.isFunction( complete ) ) {
564-
complete.call( elem );
565+
complete.call( elem[0] );
565566
}
566567
if ( $.isFunction( next ) ) {
567568
next();
568569
}
569570
}
570571

571-
effectMethod.call( elem, args, done );
572+
// if the element is hiddden and mode is hide,
573+
// or element is visible and mode is show
574+
if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
575+
done();
576+
} else {
577+
effectMethod.call( elem[0], args, done );
578+
}
572579
}
573580

574581
// TODO: remove this check in 2.0, effectMethod will always be true

0 commit comments

Comments
 (0)