You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because jQuery 4.0.0 will not transform attribute values in the getter, the
following code changes between jQuery 3.x & 4.x:
```js
$( elem ).prop( "disabled", true );
$( elem ).attr( "disabled" );
```
In jQuery 3.x, the reported attribute value is `"disabled"`, in jQuery 4.x it
will be an empty string. This may create issues when migrating so Migrate
patches and warns against it.
Add a recommendation to avoid using the `.attr()` getter on boolean attrs.
Closesgh-588
Copy file name to clipboardExpand all lines: warnings.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ This is _not_ a warning, but a console log message the plugin shows when it firs
56
56
57
57
**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.
58
58
59
-
**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">`).
59
+
**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">`). Avoid using the `.attr( name )` getter on boolean attributes, `.prop( name )` is preferred.
60
60
61
61
### \[attr-false\] JQMIGRATE: Setting the non-ARIA non-boolean attribute 'NAME' to false
0 commit comments