Skip to content

Commit 948563b

Browse files
committed
Effects: Delegate to core show/hide when the element is already in the 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.
1 parent d0ad572 commit 948563b

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

tests/unit/effects/effects.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ <h2 id="qunit-banner"></h2>
9696
<h2 id="qunit-userAgent"></h2>
9797
<ol id="qunit-tests"></ol>
9898
<div id="qunit-fixture">
99-
<div class="hidden test"></div>
99+
<div class="hidden test">
100+
<div>.</div>
101+
</div>
100102
<div class="animateClass test">
101103
<h2>Child Element Test</h2>
102104
</div>

tests/unit/effects/effects_core.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ test( "Immediate Return Conditions", function() {
2828
equal( ++count, 3, "Both Functions worked properly" );
2929
});
3030

31+
test( ".hide() with hidden parent", function() {
32+
expect( 1 );
33+
var element = $( "div.hidden" ).children();
34+
element.hide( "blind", function() {
35+
equal( element.css( "display" ), "none", "display: none" );
36+
});
37+
});
38+
3139
asyncTest( "Parse of null for options", function() {
3240
var hidden = $( "div.hidden" ),
3341
count = 0;

ui/jquery.ui.effect.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,9 +1150,10 @@ $.fn.extend({
11501150
}
11511151
}
11521152

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

0 commit comments

Comments
 (0)