question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getElmScrollRecursive fails on SVG in some browsers

See original GitHub issue

When recursing through the DOM to calculate the scroll position here: https://github.com/dequelabs/axe-core/blob/83daaa53023c8ad5ea927244617cf7807bf1fd37/lib/core/utils/scroll-state.js#L32-L40

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.

JS fiddle demonstrating issue: https://jsfiddle.net/uvftjtre/2/ (version 3.0.0.alpha.4)

Running the above example in EDGE:

Array.from: argument is not an Object

Running in IE11 will return:

TypeError: Array.from requires an array-like object - not null or undefined

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
emilyrohrboughcommented, Sep 17, 2019

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?

1reaction
benbcaicommented, Sep 16, 2019

@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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firefox error rendering an SVG image to HTML5 canvas with ...
It is working in all browsers except Firefox, which throws an error "NS_ERROR_NOT_AVAILABLE". var img = new Image(); img.src = "icon.svg"; img.
Read more >
Unable to view SVG image, any help? | Firefox Support Forum
The links on the webpages work, but the images fail to display. Attached is an example of an SVG file that fails to...
Read more >
SVG (basic support) | Can I use... Support tables for ... - CanIUse
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
5 Most Common Problems Faced by SVG Users - Vecta.io
C. You're using SVG Fonts - only supported by certain browsers · svg · defs · font · font-face · font-face · font...
Read more >
A Complete Guide to SVG Fallbacks - CSS-Tricks
Some tech-oriented web sites (like this one) can afford to say that they only support modern web browsers. But for most sites, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found