diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2025-01-16 14:15:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-16 14:15:37 +0100 |
commit | 85290c59724db69a3967885892d4305d76de058f (patch) | |
tree | cd21b382a6fc8f3ea89d420f73caf68800c2f313 /test/unit | |
parent | 9b29b10de0f64971fc2f3d4a411fbae74f2da943 (diff) | |
download | jquery-85290c59724db69a3967885892d4305d76de058f.tar.gz jquery-85290c59724db69a3967885892d4305d76de058f.zip |
Attributes: Support the `until-found` value for the `hidden` attribute
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.
That said, currently from the attributes we treat as boolean only `hidden`
has gained an extra value, let's support it.
Closes gh-5607
Ref gh-5388
Ref gh-5452
Diffstat (limited to 'test/unit')
-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 34bf579b8..b2360dfc9 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" ), "hidden", + "Values 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 ); |