8000 Tests: Backport the `hidden="until-found"` attr tests from 3.x-stable · jquery/jquery@3a31866 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a31866

Browse files
authored
Tests: Backport the hidden="until-found" attr tests from 3.x-stable
The `hidden` attribute used to be a boolean one but it gained a new `until-found` eventually. This led us to change the way we handle boolean attributes in jQuery 4.0 in gh-5452 to avoid these issues in the future. We haven't added an explicit test for the `"until-found"` value of the `hidden` attribute which triggered this decision so far, though. Backport the test from gh-5607 which landed on `3.x-stable` so that we do test it. Closes gh-5619 Ref gh-5452 Ref gh-5607 (cherry picked from commit 85290c5)
1 parent eca2a56 commit 3a31866

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/unit/attributes.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,24 @@ QUnit.test( "attr(String, Object)", function( assert ) {
479479
assert.equal( jQuery( "#name" ).attr( "nonexisting", undefined ).attr( "nonexisting" ), undefined, ".attr('attribute', undefined) does not create attribute (trac-5571)" );
480480
} );
481481

482+
QUnit.test( "attr( previously-boolean-attr, non-boolean-value)", function( assert ) {
483+
assert.expect( 3 );
484+
485+
var div = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" );
486+
487+
div.attr( "hidden", "foo" );
488+
assert.strictEqual( div.attr( "hidden" ), "foo",
489+
"Values not normalized for previously-boolean hidden attribute" );
490+
491+
div.attr( "hidden", "until-found" );
492+
assert.strictEqual( div.attr( "hidden" ), "until-found",
493+
"`until-found` value preserved for hidden attribute" );
494+
495+
div.attr( "hiDdeN", "uNtil-fOund" );
496+
assert.strictEqual( div.attr( "hidden" ), "uNtil-fOund",
497+
"`uNtil-fOund` different casing preserved" );
498+
} );
499+
482500
QUnit.test( "attr(non-ASCII)", function( assert ) {
483501
assert.expect( 2 );
484502

0 commit comments

Comments
 (0)
0