javascriptjqueryjquery-migrate

Why jQuery-migrate in not replacing depreciated functions directly in the code?


Im using jQuery-migrate on a big project. I corrected all the warnings I could but now the warnings are inside libraries.

Some libraries are not updated anymore so I can't update them to make them work with jQuery-3.3.1. Also, I can't replace the depreciated functions directly in the libraires because it is creating errors.

So I think that I'll keep jQuery-migrate in my project.

My question is : If jQuery-migrate is able to correct the depreciated functions when called, why it can not correct them directly in the code ?


Solution

  • JavaScript does not lend itself to static code analysis.

    Say you needed to replace the foo function.

    That would be fairly trivial if the code that called it was simply:

    something.foo();
    

    It becomes rather harder if it is:

    function call(bar, method) {
        bar[method]();
    }
    
    call(something, "foo");
    

    … and even harder if the logic needed to get there was more complicated.


    Creating something.foo so it just exists if anything try to access it at runtime is much simpler.