0

Before I explain the issue let me tell you I am clearly aware that jQuery removeProp should not be used on native properties such as disabled, checked and selected. https://api.jquery.com/removeProp/

We upgraded the jQuery from 1.12.3 to 3.6.0. We used the JQuery migrate plug-in to identify compatibility issues and fix all the warnings generated in console.

$(“#x”).removeProp(“disabled”) did work in 1.12.3 and stopped working after upgrading to latest version. But we were not able to identify the issue unless we tested the pages manually. I want to know why jQuery migrate plug-in did not give us a warning regarding the same.

I know we used it wrongly before and we are happy to correct it to $(“#x”).prop(“disabled”,false)

9
  • Can you post your code here? Commented May 13, 2021 at 3:39
  • I already know the fix I have to do using .prop() method. My concern is on the migrate plugin not giving warnings.
    – Akshay G
    Commented May 13, 2021 at 4:04
  • Are you sure you're using the development version of jQuery-Migrate? You don't get warnings about using obsolete interfaces if you use the production version.
    – Barmar
    Commented May 13, 2021 at 4:30
  • @Barmar yes I am using the development version, I was able to verify and fix other warnings logged in the console.
    – Akshay G
    Commented May 13, 2021 at 4:32
  • There's nothing in the documentation that says this changed between versions.
    – Barmar
    Commented May 13, 2021 at 4:37

1 Answer 1

0

This is an explanation, by Timmy Willison from jQuery Core Team in this bug report https://github.com/jquery/jquery/issues/4887

I think this is just a docs issue. We should change that to say "This can remove the property completely or have no effect at all." I followed the code and it's just calling delete, which is the right thing. 1.x used to set properties to undefined for old IE, which is no longer necessary and technically invalid.

That said, this is somewhat moot. The reason needs updating, but the recommendation remains valid. There's no reason you should need to remove a native property (nor should you expect that to work–Blink is making it impossible anyway). It's not the same as removing a content attribute, which would actually set the corresponding property to false. Setting to false is the right thing here.

The issue raised resulted in the change in the documentation of .removeProp(). https://github.com/jquery/api.jquery.com/pull/1189

Not the answer you're looking for? Browse other questions tagged or ask your own question.