diff --git a/lib/core/utils/flattened-tree.js b/lib/core/utils/flattened-tree.js index 786390fc7e..f5a8cfb63a 100644 --- a/lib/core/utils/flattened-tree.js +++ b/lib/core/utils/flattened-tree.js @@ -89,7 +89,7 @@ axe.utils.getFlattenedTree = function (node, shadowId) { if (nodeName === 'content') { realArray = Array.from(node.getDistributedNodes()); return realArray.reduce(reduceShadowDOM, []); - } else if (nodeName === 'slot') { + } else if (nodeName === 'slot' && typeof node.assignedNodes === 'function') { realArray = Array.from(node.assignedNodes()); if (!realArray.length) { // fallback content diff --git a/test/core/utils/flattened-tree.js b/test/core/utils/flattened-tree.js index 7c42771973..38d7661634 100644 --- a/test/core/utils/flattened-tree.js +++ b/test/core/utils/flattened-tree.js @@ -231,6 +231,13 @@ describe('axe.utils.getFlattenedTree', function() { assert.equal(virtualDOM[0].actualNode, vNode.actualNode); }); }); + } else { + it('does not throw when slot elements are used', function () { + fixture.innerHTML = ''; + assert.doesNotThrow(function () { + axe.utils.getFlattenedTree(fixture); + }); + }); } if (shadowSupport.undefined) {