diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2025-02-24 23:56:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-24 23:56:11 +0100 |
commit | 3a31866b80844d8bb06084c70c5b788dd129f7e8 (patch) | |
tree | b4e0ab1f3c8b8cfd57313d7749f623411d05fd83 | |
parent | eca2a56457e1c40c071aeb3ac87efeb8bbb8013e (diff) | |
download | jquery-3a31866b80844d8bb06084c70c5b788dd129f7e8.tar.gz jquery-3a31866b80844d8bb06084c70c5b788dd129f7e8.zip |
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 85290c59724db69a3967885892d4305d76de058f)
-rw-r--r-- | test/unit/attributes.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/unit/attributes.js b/test/unit/attributes.js index a54f2d65d..5ace087b9 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -479,6 +479,24 @@ QUnit.test( "attr(String, Object)", function( assert ) { assert.equal( jQuery( "#name" ).attr( "nonexisting", undefined ).attr( "nonexisting" ), undefined, ".attr('attribute', undefined) does not create attribute (trac-5571)" ); } ); +QUnit.test( "attr( previously-boolean-attr, non-boolean-value)", function( assert ) { + assert.expect( 3 ); + + var div = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" ); + + div.attr( "hidden", "foo" ); + assert.strictEqual( div.attr( "hidden" ), "foo", + "Values not normalized for previously-boolean hidden attribute" ); + + div.attr( "hidden", "until-found" ); + assert.strictEqual( div.attr( "hidden" ), "until-found", + "`until-found` value preserved for hidden attribute" ); + + div.attr( "hiDdeN", "uNtil-fOund" ); + assert.strictEqual( div.attr( "hidden" ), "uNtil-fOund", + "`uNtil-fOund` different casing preserved" ); +} ); + QUnit.test( "attr(non-ASCII)", function( assert ) { assert.expect( 2 ); |