-
Notifications
You must be signed in to change notification settings - Fork 795
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
getElmScrollRecursive fails on SVG in some browsers #525
Comments
See: dequelabs/axe-core#525 If the code encounters an SVG it essentially runs, document.querySelector('svg').children. This doesn't always return an HTMLCollection object which in turn causes Array.from to error.
Problem turns out to be that .children is undefined. The work around is to use .childNodes instead and filter them for elements. |
@WilcoFiers This issue causes our accessibility tests to fail on any page that contains an SVG element. Looks like this is scheduled to be fixed in axe-core 3.4. Do you have a timeframe when 3.4 is scheduled to be released? |
Do you expect the changes be to add fallback for childNodes like: - return Array.from(root.children).reduce((scrolls, elm) => {
+ return Array.from(root.children || root.childNodes || []).reduce((scrolls, elm) => { or are the scroll position of SVG children necessary to worry about? |
Another option could be something like this. + var i = 0
+ var node;
+ var nodes = root.childNodes;
+ var children = [];
+ while (node = nodes[i++]) {
+ if (node.nodeType === Node.ELEMENT_NODE) {
+ children.push(node);
+ }
+ }
- return Array.from(root.children).reduce((scrolls, elm) => {
+ return Array.from(children).reduce((scrolls, elm) => { @WilcoFiers @straker What are your thoughts? |
@WilcoFiers @straker When do you plan to release 3.3.3/3.4.0 so that my project can consume the release with this fix? |
@WilcoFiers @straker Just wanted to follow up to see when you plan to release the next version of axe-core so my team can consume this fix. |
@WilcoFiers @straker You may ignore my question above. Just noticed the release date here: https://github.com/dequelabs/axe-core/milestone/11 |
When recursing through the DOM to calculate the scroll position here:
axe-core/lib/core/utils/scroll-state.js
Lines 32 to 40 in 83daaa5
If the code encounters an SVG it essentially runs,
document.querySelector('svg').children
. This doesn't always return an HTMLCollection object which in turn causesArray.from
to error.JS fiddle demonstrating issue:
https://jsfiddle.net/uvftjtre/2/ (version 3.0.0.alpha.4)
Running the above example in EDGE:
Running in IE11 will return:
This error surfaced when running automated tests through Phantom JS 1.9.7
More context:
https://stackoverflow.com/questions/7935689/what-is-the-difference-between-children-and-childnodes-in-javascript#7935719
The text was updated successfully, but these errors were encountered: