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(byRole): Don't assume window context #378

Merged
merged 2 commits into from Oct 10, 2019

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Oct 10, 2019

What:

Get window from passed element

Why:

element might be passed from another window/frame

How:

Use element.ownerDocument.defaultView. This is safe to evaluate since we expect an Element. ownerDocument is only null for Document (https://developer.mozilla.org/en-US/docs/Web/API/Node/ownerDocument)

Checklist:

  • [ ] Documentation added to the
    docs site
  • ~[ ] I've prepared a PR for types targetting ~https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/testing-library__dom
  • Tests: To be honest I wouldn't know if these can create different results. As far as I know getComputedStyle never reads from its window (this) but only from the window of the passed element (at least the jsdom implementation). So from my knowledge this is only useful if you run inside node without a global DOM.
  • Ready to be merged

@eps1lon eps1lon added the bug Something isn't working label Oct 10, 2019
@eps1lon eps1lon changed the title fix(shouldExcludeFromA11yTree): Don't assume window context fix(byRole): Don't assume window context Oct 10, 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.

Despite #377, I think we're good to go forward with this one.

@kentcdodds kentcdodds merged commit bb3c145 into testing-library:master Oct 10, 2019
@kentcdodds
Copy link
Member

🎉 This PR is included in version 6.7.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@eps1lon eps1lon mentioned this pull request Oct 20, 2019
@eps1lon eps1lon deleted the fix/a11y-window branch September 7, 2021 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants