Skip to content

Commit

Permalink
Effects: Delegate to core show/hide when the element is already in th…
Browse files Browse the repository at this point in the history
…e correct final state. This forces the element to go through the olddisplay tracking and forces styles on elements even if they're hidden via an ancestor. Fixes #9120 - Effects: .hide() inconsistent with core with a hidden parent.
  • Loading branch information
scottgonzalez committed Feb 26, 2013
1 parent d0ad572 commit 948563b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tests/unit/effects/effects.html
Expand Up @@ -96,7 +96,9 @@ <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
<div class="hidden test"></div>
<div class="hidden test">
<div>.</div>
</div>
<div class="animateClass test">
<h2>Child Element Test</h2>
</div>
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/effects/effects_core.js
Expand Up @@ -28,6 +28,14 @@ test( "Immediate Return Conditions", function() {
equal( ++count, 3, "Both Functions worked properly" );
});

test( ".hide() with hidden parent", function() {
expect( 1 );
var element = $( "div.hidden" ).children();
element.hide( "blind", function() {
equal( element.css( "display" ), "none", "display: none" );
});
});

asyncTest( "Parse of null for options", function() {
var hidden = $( "div.hidden" ),
count = 0;
Expand Down
5 changes: 3 additions & 2 deletions ui/jquery.ui.effect.js
Expand Up @@ -1150,9 +1150,10 @@ $.fn.extend({
}
}

// if the element is hiddden and mode is hide,
// or element is visible and mode is show
// If the element already has the correct final state, delegate to
// the core methods so the internal tracking of "olddisplay" works.
if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
elem[ mode ]();
done();
} else {
effectMethod.call( elem[0], args, done );
Expand Down

0 comments on commit 948563b

Please sign in to comment.