Skip to content

Commit 41905cc

Browse files
committed
fixup! Attributes: Restore boolean attribute & false setter treatment from 3.x
1 parent 65a03af commit 41905cc

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/jquery/attributes.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jQuery.each( booleans.split( "|" ), function( _i, name ) {
3030
attrValue = elem.getAttribute( name );
3131

3232
if ( attrValue !== name && attrValue != null &&
33-
( extraBoolAttrValues[ name ] || [] ).indexOf( attrValue ) === -1
33+
( extraBoolAttrValues[ name ] || [] )
34+
.indexOf( String( attrValue ).toLowerCase() ) === -1
3435
) {
3536
migrateWarn( "boolean-attributes",
3637
"Boolean attribute '" + name +
@@ -53,7 +54,8 @@ jQuery.each( booleans.split( "|" ), function( _i, name ) {
5354
set: origAttrHooks.set || function( elem, value, name ) {
5455
if ( jQuery.migrateIsPatchEnabled( "boolean-attributes" ) ) {
5556
if ( value !== name &&
56-
( extraBoolAttrValues[ name ] || [] ).indexOf( value ) === -1
57+
( extraBoolAttrValues[ name ] || [] )
58+
.indexOf( String( value ).toLowerCase() ) === -1
5759
) {
5860
if ( value !== false ) {
5961
migrateWarn( "boolean-attributes",

test/unit/jquery/attributes.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ QUnit.module( "attributes" );
1212
QUnit.test( ".attr( boolean attribute ) - patch " +
1313
( patchEnabled ? "enabled" : "disabled" ),
1414
function( assert ) {
15-
assert.expect( 31 );
15+
assert.expect( 33 );
1616

1717
if ( !patchEnabled ) {
1818
jQuery.migrateDisablePatches( "boolean-attributes" );
@@ -187,6 +187,23 @@ QUnit.module( "attributes" );
187187
"Setting aria attributes to false is not affected by boolean settings"
188188
);
189189
} );
190+
191+
expectNoWarning( assert, "extra ex-boolean attrs values", function() {
192+
var $input = jQuery( "<input />" );
193+
194+
$input.attr( "hidden", "until-found" );
195+
196+
if ( jQueryVersionSince( "4.0.0" ) ) {
197+
assert.equal(
198+
$input.attr( "hidden" ),
199+
"until-found",
200+
"Extra values of ex-boolean attributes are not changed"
201+
);
202+
} else {
203+
assert.ok( true,
204+
"Extra ex-boolean attrs values not supported under jQuery 3.x" );
205+
}
206+
} );
190207
} );
191208
}
192209

0 commit comments

Comments
 (0)