Closed simonihmig closed 7 years ago
I do still think we want the conceptual changes from @scalvert’s PR (rebased against this) so that even jQuery pseudo selectors and imports that cannot be analyazed can properly be migrated to use the native helpers.
That makes sense, good point! @scalvert can you update your PR?
Fixes #27.
Alternative approach to #28. This uses
ast-types
' scope feature to check the value of a selector given as a variable, and only do the transformation if it does not contain any jQuery specific selector extensions.This uses the test case added by @scalvert, with one exception: the non-standard
.foo:eq(n)
selector is not migrated tofindAll('.foo')[n]
when the selector is given as a variable. (Still works when given as a string literal)The good thing here is that any standard-compliant selector given as a variable will correctly transform without any jQuery leftovers (I hope so, tests are passing at least). See the
jq-extensions.(input|output).js
test fixtures.@scalvert @rwjblue Hope that makes sense to you! Please drop your feedback if you see any problems with this approach!