Skip to content

Only warn against removeAttr(booleanAttr) if property value not false #471

@mgol

Description

@mgol

Migrate warns against .removeAttr() called on boolean attributes as this used to set the associated property to false but it doesn't do so anymore since jQuery 3.0.0.

However, this is only an issue if the property wasn't already set to false. There are valid reasons to call removeAttr on boolean attributes and it shouldn't cause issues as long as the property is being updated first.

This is not just a theoretical concern - AngularJS sets both boolean properties & then associated attributes, calling removeAttr if the value passed was false. See a report about that at angular/angular.js#16877. I also hit it at my employer when updating jQuery.

The proposal is to read the property and if it's already false, skip the warning.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions