aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2016-01-07 14:06:41 -0500
committerTimmy Willison <timmywillisn@gmail.com>2016-01-07 14:06:41 -0500
commita4d16a26abe3ea36337f7bfc4d1bfe13b893cd17 (patch)
tree00421e5ac4e6a5c7d857b3fd86f271078a9d5fa7 /test
parent1823a715660a5f31dd7e05672e9ad020066256a9 (diff)
downloadjquery-a4d16a26abe3ea36337f7bfc4d1bfe13b893cd17.tar.gz
jquery-a4d16a26abe3ea36337f7bfc4d1bfe13b893cd17.zip
Revert "Attributes: Remove undocumented .toggleClass( boolean ) signature"
This reverts commit 53f798cf4d783bb813b4d1ba97411bc752b275f3. - Turns out this is documented, even if not fully. Need to deprecate before removal.
Diffstat (limited to 'test')
-rw-r--r--test/unit/attributes.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index cbf83d0ec..7f92d3505 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -1239,7 +1239,7 @@ QUnit.test( "removeClass(undefined) is a no-op", function( assert ) {
} );
var testToggleClass = function( valueObj, assert ) {
- assert.expect( 11 );
+ assert.expect( 19 );
var e = jQuery( "#firstp" );
assert.ok( !e.is( ".test" ), "Assert class not present" );
@@ -1267,6 +1267,29 @@ var testToggleClass = function( valueObj, assert ) {
assert.ok( ( e.is( ".testA.testC" ) && !e.is( ".testB" ) ), "Assert 1 class added, 1 class removed, and 1 class kept" );
e.toggleClass( valueObj( "testA testC" ) );
assert.ok( ( !e.is( ".testA" ) && !e.is( ".testB" ) && !e.is( ".testC" ) ), "Assert no class present" );
+
+ // toggleClass storage
+ e.toggleClass( true );
+ assert.ok( e[ 0 ].className === "", "Assert class is empty (data was empty)" );
+ e.addClass( "testD testE" );
+ assert.ok( e.is( ".testD.testE" ), "Assert class present" );
+ e.toggleClass();
+ assert.ok( !e.is( ".testD.testE" ), "Assert class not present" );
+ assert.ok( jQuery._data( e[ 0 ], "__className__" ) === "testD testE", "Assert data was stored" );
+ e.toggleClass();
+ assert.ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" );
+ e.toggleClass( false );
+ assert.ok( !e.is( ".testD.testE" ), "Assert class not present" );
+ e.toggleClass( true );
+ assert.ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" );
+ e.toggleClass();
+ e.toggleClass( false );
+ e.toggleClass();
+ assert.ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" );
+
+ // Cleanup
+ e.removeClass( "testD" );
+ assert.expectJqData( this, e[ 0 ], "__className__" );
};
QUnit.test( "toggleClass(String|boolean|undefined[, boolean])", function( assert ) {