Skip to content

Use innerText rather than textContent for label queries. #190

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

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function queryAllLabelsByText(
const matcher = exact ? matches : fuzzyMatches
const matchNormalizer = makeNormalizer({collapseWhitespace, trim, normalizer})
return Array.from(container.querySelectorAll('label')).filter(label =>
matcher(label.textContent, label, text, matchNormalizer),
matcher(label.innerText || label.textContent, label, text, matchNormalizer),
Copy link
Member

Choose a reason for hiding this comment

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

Actually, I think it may be better to:

  1. Change this to: matcher(getNodeText(label), label, text, matchNormalizer),
  2. Update getNodeText to try innerText before textContent

This way we get the benefit of using innerText for all text selectors.

Could you make that adjustment here please?

Copy link
Author

Choose a reason for hiding this comment

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

I will sent it with a test.

)
}

Expand Down