jquery-migrate icon indicating copy to clipboard operation
jquery-migrate copied to clipboard

Only warn against `removeAttr(booleanAttr)`

Open mgol opened this issue 3 years ago • 0 comments

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 https://github.com/angular/angular.js/issues/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.

mgol avatar Aug 11 '22 15:08 mgol