Skip to content

Commit e7d2688

Browse files
committed
squash! Fixes per code review
1 parent f4ae007 commit e7d2688

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

test/attributes.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ QUnit.test( ".removeAttr( boolean attribute )", function( assert ) {
4242

4343
} );
4444

45-
QUnit.test( "", function( assert ) {
46-
assert.expect( 13 );
45+
QUnit.test( ".toggleClass( boolean )", function( assert ) {
46+
assert.expect( 14 );
4747

4848
var e = jQuery( "<div />" ).appendTo( "#qunit-fixture" );
4949

@@ -52,22 +52,29 @@ QUnit.test( "", function( assert ) {
5252
assert.equal( e[ 0 ].className, "", "Assert class is empty (data was empty)" );
5353
} );
5454

55-
expectNoWarning( "toggleClass not full className", function() {
55+
expectNoWarning( ".toggleClass( string ) not full className", function() {
5656
e.attr( "class", "" );
5757
e.toggleClass( "classy" );
5858
assert.equal( e.attr( "class" ), "classy", "class was toggle-set" );
5959
e.toggleClass( "classy", false );
6060
assert.equal( e.attr( "class" ), "", "class was toggle-removed" );
6161
} );
6262

63-
expectWarning( "toggleClass full-className manipulations", function() {
63+
expectWarning( ".toggleClass() save and clear", 1, function() {
6464
e.addClass( "testD testE" );
6565
assert.ok( e.is( ".testD.testE" ), "Assert class present" );
6666
e.toggleClass();
6767
assert.ok( !e.is( ".testD.testE" ), "Assert class not present" );
68-
assert.equal( jQuery.data( e[ 0 ], "__className__" ), "testD testE", "Data was stored" );
68+
69+
// N.B.: Store should have "testD testE" now, next test will assert that
70+
} );
71+
72+
expectWarning( ".toggleClass() restore", 1, function() {
6973
e.toggleClass();
7074
assert.ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" );
75+
} );
76+
77+
expectWarning( ".toggleClass( boolean )", 1, function() {
7178
e.toggleClass( false );
7279
assert.ok( !e.is( ".testD.testE" ), "Assert class not present" );
7380
e.toggleClass( true );

warnings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ See jQuery-ui [commit](https://github.com/jquery/jquery-ui/commit/c0093b599fcd58
167167

168168
**Solution:** Rename any of the older usage to `jQuery.expr.pseudos`. The functionality is identical.
169169

170-
### JQMIGRATE: jQuery.fn.toggleClass( boolean ) is deprecated
170+
### JQMIGRATE: jQuery.fn.toggleClass( [ boolean ] ) is deprecated
171171

172-
**Cause:** Calling `.toggleClass()` with no arguments or with a single Boolean `true` or `false` argument has been deprecated. Its behavior was poorly documented, but essentially the method saved away the current `class` value in a data item when the class was removed and restored the saved value when it was toggled back. If you do not believe you are specificially trying to use this form of the method, it is possible you are accidentally doing so via an inadvertent undefined value, as `.toggleClass( undefined )` toggles all classes.
172+
**Cause:** Calling `.toggleClass()` with no arguments, or with a single Boolean `true` or `false` argument, has been deprecated. Its behavior was poorly documented, but essentially the method saved away the current `class` value in a data item when the class was removed and restored the saved value when it was toggled back. If you do not believe you are specificially trying to use this form of the method, it is possible you are accidentally doing so via an inadvertent undefined value, as `.toggleClass( undefined )` toggles all classes.
173173

174174
**Solution:** If this functionality is still needed, save the current full `.attr( "class" )` value in a data item and restore it when required.

0 commit comments

Comments
 (0)