8000 Attributes: Warn & restore boolean attribute & false setter treatment from 3.x by mgol · Pull Request #540 · jquery/jquery-migrate · GitHub
[go: up one dir, main page]

Skip to content

Attributes: Warn & restore boolean attribute & false setter treatment from 3.x #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! Attributes: Restore boolean attribute & false setter treatment…
… from 3.x
  • Loading branch information
mgol committed Oct 29, 2024
commit d0ff2c2fb7de58ae64e41c1dfcd05da856d1d78a
6 changes: 4 additions & 2 deletions src/jquery/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jQuery.each( booleans.split( "|" ), function( _i, name ) {
attrValue = elem.getAttribute( name );

if ( attrValue !== name && attrValue != null &&
( extraBoolAttrValues[ name ] || [] ).indexOf( attrValue ) === -1
( extraBoolAttrValues[ name ] || [] )
.indexOf( String( attrValue ).toLowerCase() ) === -1
) {
migrateWarn( "boolean-attributes",
"Boolean attribute '" + name +
Expand All @@ -53,7 +54,8 @@ jQuery.each( booleans.split( "|" ), function( _i, name ) {
set: origAttrHooks.set || function( elem, value, name ) {
if ( jQuery.migrateIsPatchEnabled( "boolean-attributes" ) ) {
if ( value !== name &&
( extraBoolAttrValues[ name ] || [] ).indexOf( value ) === -1
( extraBoolAttrValues[ name ] || [] )
.indexOf( String( value ).toLowerCase() ) === -1
) {
if ( value !== false ) {
migrateWarn( "boolean-attributes",
Expand Down
19 changes: 18 additions & 1 deletion test/unit/jquery/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ QUnit.module( "attributes" );
QUnit.test( ".attr( boolean attribute ) - patch " +
( patchEnabled ? "enabled" : "disabled" ),
function( assert ) {
assert.expect( 31 );
assert.expect( 33 );

if ( !patchEnabled ) {
jQuery.migrateDisablePatches( "boolean-attributes" );
Expand Down Expand Up @@ -187,6 +187,23 @@ QUnit.module( "attributes" );
"Setting aria attributes to false is not affected by boolean settings"
);
} );

expectNoWarning( assert, "extra ex-boolean attrs values", function() {
var $input = jQuery( "<input />" );

$input.attr( "hidden", "until-found" );

if ( jQueryVersionSince( "4.0.0" ) ) {
assert.equal(
$input.attr( "hidden" ),
"until-found",
"Extra values of ex-boolean attributes are not changed"
);
} else {
assert.ok( true,
"Extra ex-boolean attrs values not supported under jQuery 3.x" );
}
} );
} );
}

Expand Down
Loading
0