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

IE11, svg with tabindex=0 does not have tabIndex property #24

Closed
straker opened this issue Apr 25, 2018 · 4 comments
Closed

IE11, svg with tabindex=0 does not have tabIndex property #24

straker opened this issue Apr 25, 2018 · 4 comments

Comments

@straker
Copy link

straker commented Apr 25, 2018

In IE11, a SVG with tabindex="0" does not have a tabIndex property so gets added to the orderedTabbables array no matter where it is in the DOM.

candidateIndex = parseInt(candidate.getAttribute('tabindex'), 10) || candidate.tabIndex;

Always triggers the OR condition if tabindex="0", which then assumes tabIndex is a valid property. SVGs return undefined for the tabIndex property.

@straker straker changed the title IE11, svg with tabindex does not have tabIndex property IE11, svg with tabindex=0 does not have tabIndex property Apr 25, 2018
@davidtheclark
Copy link
Collaborator

Yep, looks like a typical forgot-to-remember-that-zero-is-falsy accident. Thanks for pointing this out.

@davidtheclark
Copy link
Collaborator

🤔 In theory I see that there should be a possible bug here. And we should change the code regardless. But I want to make sure I'm fixing the problem you're reporting ... and I'm actually having trouble reproducing it, @straker.

I added a new test case with the following HTML:

<svg id="svg-1" height="100" width="100" tabindex="0">
  <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
</svg>
<svg id="svg-2" height="100" width="100" tabindex="-1">
  <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="blue" />
</svg>
<svg id="svg-3" height="100" width="100">
  <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="green" />
</svg>

As expected, running tabbable on this case returns an array with only the first SVG — both in Chrome and in IE11. So, things actually seem to be working ok?

Could you please explain more about what the difference between expected and actual behavior is?

(Also: IE11 and maybe some Edge versions through everything off by making <svg> elements focusable by default, and you need to turn that off with focusable="false" if you want behavior to match other browsers. Maybe should document this caveat in the README, since I don't know a way around it.)

@straker
Copy link
Author

straker commented Apr 30, 2018 via email

@davidtheclark
Copy link
Collaborator

Ah, I see. Will fix up my test case to confirm the fix to that problem.

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

No branches or pull requests

2 participants