diff --git a/lib/core/utils/scroll-state.js b/lib/core/utils/scroll-state.js index c1b66d04d5..3fe7261006 100644 --- a/lib/core/utils/scroll-state.js +++ b/lib/core/utils/scroll-state.js @@ -14,13 +14,16 @@ function setScroll(elm, top, left) { * Create an array scroll positions from descending elements */ function getElmScrollRecursive(root) { - return Array.from(root.children).reduce((scrolls, elm) => { - const scroll = axe.utils.getScroll(elm); - if (scroll) { - scrolls.push(scroll); - } - return scrolls.concat(getElmScrollRecursive(elm)); - }, []); + return Array.from(root.children || root.childNodes || []).reduce( + (scrolls, elm) => { + const scroll = axe.utils.getScroll(elm); + if (scroll) { + scrolls.push(scroll); + } + return scrolls.concat(getElmScrollRecursive(elm)); + }, + [] + ); } /** diff --git a/test/core/utils/scroll-state.js b/test/core/utils/scroll-state.js index 8df4d6700c..f7b1d4f18f 100644 --- a/test/core/utils/scroll-state.js +++ b/test/core/utils/scroll-state.js @@ -125,6 +125,17 @@ describe('axe.utils.getScrollState', function() { }) ); }); + + it('does not fail with svg elements', function() { + fixture.innerHTML = + '' + + '' + + ''; + + assert.doesNotThrow(function() { + getScrollState(); + }); + }); }); describe('axe.utils.setScrollState', function() {