Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix node.matches is not a function #216

Merged
merged 2 commits into from
Feb 15, 2019

Conversation

valscion
Copy link
Contributor

@valscion valscion commented Feb 15, 2019

Fixes #215

What:

Fixes the error caused by loose mode transpilation as spotted by @lavigneer:

No, there aren't any elements in that NodeList that are also a NodeList

I just tested wrapping container.querySelectorAll(selector) explicitly in an Array.from call in the built .esm bundle and that appeared to resolve the issue.

The transpilation of
Array.from([...baseArray, ...container.querySelectorAll(selector)])
results in
Array.from([].concat(baseArray, container.querySelectorAll(selector)))
so it's not converting the NodeList to an array and is just trying to concat it directly

Why:

To fix regression

How:

Explicitly use Array.from to force the NodeList to be converted to an array and spread correctly.

Checklist:

  • Documentation added to the docs site N/A
  • Typescript definitions updated N/A
  • Tests N/A can't be tested as bug is in transpilation
  • Ready to be merged
  • Added myself to contributors table

src/queries.js Outdated Show resolved Hide resolved
@alexkrolick alexkrolick mentioned this pull request Feb 15, 2019
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kentcdodds kentcdodds merged commit 4c17512 into testing-library:master Feb 15, 2019
@valscion valscion deleted the patch-1 branch February 15, 2019 20:14
@kentcdodds
Copy link
Member

🎉 This PR is included in version 3.16.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getByText throws node.matches is not a function
2 participants