simonihmig / ember-native-dom-helpers-codemod

Codemod to transform your jQuery based ember tests to use ember-native-dom-helpers
MIT License
27 stars 9 forks source link

Check for jq extensions in selectors given as vars #29

Closed simonihmig closed 6 years ago

simonihmig commented 6 years ago

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 to findAll('.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!

simonihmig commented 6 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?