diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2016-04-04 09:58:14 -0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2016-04-11 13:21:11 -0400 |
commit | 755e7ccf018eb150eddefe78063a9ec58b3229e3 (patch) | |
tree | a54c23d4201838b82d2687218992d39bee226b3c /test | |
parent | ce6c83f710c28108ccb4d50a7b924baa890dc961 (diff) | |
download | jquery-755e7ccf018eb150eddefe78063a9ec58b3229e3.tar.gz jquery-755e7ccf018eb150eddefe78063a9ec58b3229e3.zip |
CSS: Toggle detached elements as visible unless they have display: none
Fixes gh-2863
Closes gh-3037
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/css.js | 24 | ||||
-rw-r--r-- | test/unit/effects.js | 21 |
2 files changed, 41 insertions, 4 deletions
diff --git a/test/unit/css.js b/test/unit/css.js index 26660ab4f..e04ad5dea 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -926,6 +926,30 @@ QUnit[ jQuery.find.compile && jQuery.fn.toggle ? "test" : "skip" ]( "toggle()", jQuery.fn.hide = oldHide; } ); +QUnit[ jQuery.find.compile && jQuery.fn.toggle ? "test" : "skip" ]( "detached toggle()", function( assert ) { + assert.expect( 6 ); + var detached = jQuery( "<p><a/><p>" ).find( "*" ).addBack(), + hiddenDetached = jQuery( "<p><a/></p>" ).find( "*" ).addBack().css( "display", "none" ), + cascadeHiddenDetached = jQuery( "<p><a/></p>" ).find( "*" ).addBack().addClass( "hidden" ); + + detached.toggle(); + detached.appendTo( "#qunit-fixture" ); + assert.equal( detached[ 0 ].style.display, "none", "detached element" ); + assert.equal( detached[ 1 ].style.display, "none", "element in detached tree" ); + + hiddenDetached.toggle(); + hiddenDetached.appendTo( "#qunit-fixture" ); + assert.equal( hiddenDetached[ 0 ].style.display, "", "detached, hidden element" ); + assert.equal( hiddenDetached[ 1 ].style.display, "", "hidden element in detached tree" ); + + cascadeHiddenDetached.toggle(); + cascadeHiddenDetached.appendTo( "#qunit-fixture" ); + assert.equal( cascadeHiddenDetached[ 0 ].style.display, "none", + "detached, cascade-hidden element" ); + assert.equal( cascadeHiddenDetached[ 1 ].style.display, "none", + "cascade-hidden element in detached tree" ); +} ); + QUnit.test( "jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function( assert ) { assert.expect( 4 ); diff --git a/test/unit/effects.js b/test/unit/effects.js index 0f5eaa415..5f1913575 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -1547,15 +1547,17 @@ QUnit.test( "animate should set display for disconnected nodes", function( asser assert.expect( 20 ); var env = this, - methods = { - toggle: [ 1 ], - slideToggle: [], + showMethods = { fadeIn: [], fadeTo: [ "fast", 0.5 ], slideDown: [ "fast" ], show: [ 1 ], animate: [ { width: "show" } ] }, + toggleMethods = { + toggle: [ 1 ], + slideToggle: [] + }, $divEmpty = jQuery( "<div/>" ), $divTest = jQuery( "<div>test</div>" ), $divNone = jQuery( "<div style='display: none;'/>" ), @@ -1578,7 +1580,7 @@ QUnit.test( "animate should set display for disconnected nodes", function( asser assert.expectJqData( env, $divNone[ 0 ], "olddisplay" ); - jQuery.each( methods, function( name, opt ) { + jQuery.each( showMethods, function( name, opt ) { jQuery.fn[ name ].apply( jQuery( "<div/>" ), opt.concat( [ function() { assert.strictEqual( jQuery( this ).css( "display" ), nullParentDisplay, "." + name + " block with null parentNode" ); @@ -1589,6 +1591,17 @@ QUnit.test( "animate should set display for disconnected nodes", function( asser "." + name + " block under fragment" ); } ] ) ); } ); + jQuery.each( toggleMethods, function( name, opt ) { + jQuery.fn[ name ].apply( jQuery( "<div/>" ), opt.concat( [ function() { + assert.strictEqual( jQuery( this ).css( "display" ), "none", + "." + name + " block with null parentNode" ); + } ] ) ); + + jQuery.fn[ name ].apply( jQuery( "<div>test</div>" ), opt.concat( [ function() { + assert.strictEqual( jQuery( this ).css( "display" ), "none", + "." + name + " block under fragment" ); + } ] ) ); + } ); clock.tick( 400 ); } ); |