Skip to content

fix: shouldExcludeFromA11yTree runs in IE11 #365

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

Conversation

briandipalma
Copy link
Contributor

IE11 returns undefined for missing parentElement.

fix: In IE11 when an element lacks parentElement it returns undefined instead of null.

Why: Because otherwise you get these errors

TypeError: Unable to get property 'hidden' of undefined or null reference
	error properties: Object({ number: -2146823281 })
	    at <Jasmine>
	   at shouldExcludeFromA11yTree (eval code:824:5)
	   at Anonymous function (eval code:995:5)
	   at Anonymous function (eval code:28:7)
	   at filter (eval code:11:5)
	   at queryAllByRole (eval code:994:3)

Checklist:

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

I couldn't find any documentation for that. Only that parentElement isn't implemented for Node which would explain the undefined value. But this leads to the question why there is a Node passed to this function in the first place.

It might make more sense to throw if this is getting passed a Node since there is no specification for what kind of nodes should be part of the a11y tree. It's only defined for Element.

@eps1lon
Copy link
Member

eps1lon commented Oct 1, 2019

Could you include a reproduction that fails with IE 11? This would help a lot 🙏

@briandipalma
Copy link
Contributor Author

Yes it seems like it's not implemented on Node Only supported on Element. from https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement

But the element that failed for us was an SVG and I found this: https://stackoverflow.com/a/36270354/1927079

In Internet Explorer, parentElement is undefined for SVG elements, whereas parentNode is defined.

Do your tests run in IE11?

@eps1lon
Copy link
Member

eps1lon commented Oct 1, 2019

But the element that failed for us was an SVG and I found this:

Interesting. I'll verify that and add it to the MDN docs since SVGElement inherits from Element.

Do your tests run in IE11?

We don't run any tests in browsers and so far browser support hasn't been a priority from what I can tell. I use this library in browser tests though so anytime I do find one I'll try to fix it (#362, #363).

@briandipalma
Copy link
Contributor Author

I'll try and add a test that covers the failure I see here.

@briandipalma briandipalma force-pushed the pr/fix-shouldExcludeFromA11yTree-IE11 branch from d8c1af1 to 22407fb Compare October 1, 2019 13:43
@briandipalma
Copy link
Contributor Author

Added a test but this would only ever fail in IE11.

@eps1lon
Copy link
Member

eps1lon commented Oct 1, 2019

Could you write the test so that you only use public methods? Then I could verify this with a test suite running in IE 11 (via browserstack) as I'm still not convinced this is the source of the issue.

@briandipalma briandipalma force-pushed the pr/fix-shouldExcludeFromA11yTree-IE11 branch from 22407fb to ab3f7c7 Compare October 3, 2019 09:28
IE11 returns `undefined` for missing `parentElement`.
@briandipalma
Copy link
Contributor Author

Updated the tests, is this what you were thinking?

@briandipalma
Copy link
Contributor Author

Is this OK?

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.

This LGTM :) Thanks!

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

🎉 This PR is included in version 6.5.1 🎉

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.

3 participants