Skip to content

Commit

Permalink
Attributes: Update warnings.md to not mention jQuery 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mgol committed Nov 19, 2024
1 parent 6c9b875 commit 8761004
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions warnings.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ This is _not_ a warning, but a console log message the plugin shows when it firs
### \[boolean-attributes\] JQMIGRATE: Boolean attribute 'NAME' value is different from its lowercased name
### \[boolean-attributes\] JQMIGRATE: Boolean attribute 'NAME' value is not set to its lowercased name

**Cause**: Prior to jQuery 4.0, when calling `.attr( name, value )` with any non-`false` non-`null` `value`, jQuery would actually set it to `name`. Similarly, regardless of the actual value, `.attr( name )` used to return `name` lowercased. jQuery 4.0 removes this special behavior.
**Cause**: When calling `.attr( name, value )` with any non-`false` non-`null` `value`, jQuery would actually set it to `name`. Similarly, regardless of the actual value, `.attr( name )` used to return `name` lowercased. This behavior is deprecated.

**Solution**: Always set boolean attributes to their names, whether when using jQuery (`.attr( name, name )`), native APIs (`.setAttribute( name, name )`) or directly in HTML (`<input checked="checked">`).

### \[attr-false\] JQMIGRATE: Setting the non-ARIA non-boolean attribute 'NAME' to false

**Cause**: Prior to jQuery 4.0, calling `.attr( name, false )` was only removing the attribute when `name` was a boolean attribute; otherwise, it was setting the attribute value to `"false"`. In jQuery 4.x, it will remove any non-ARIA attribute.
**Cause**: Calling `.attr( name, false )` only removes the attribute when `name` is a boolean attribute; otherwise, it sets the attribute value to `"false"`. This behavior is deprecated for non-ARIA attributes.

**Solution**: If you want to set the value of an attribute to `"false"`, wrap it in quotes: `.attr( name, "false" )`.

Expand Down

0 comments on commit 8761004

Please sign in to comment.