diff --git a/eslint.config.js b/eslint.config.js index 091ce2f0c9..294c01de53 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -84,6 +84,20 @@ module.exports = [ 'CallExpression[callee.object.property.name=actualNode][callee.property.name=contains]', message: "Don't use node.contains(node2) as it doesn't work across shadow DOM. Use axe.utils.contains(node, node2) instead." + }, + { + // window.HTMLElement + selector: + 'MemberExpression[object.name=window][property.name=HTMLElement]', + message: + "Don't use window.HTMLElement as it doesn't include all DOM node types, such as SVGs. Use window.Node instead." + }, + { + // globalThis.HTMLElement + selector: + 'MemberExpression[object.name=globalThis][property.name=HTMLElement]', + message: + "Don't use globalThis.HTMLElement as it doesn't include all DOM node types, such as SVGs. Use globalThis.Node instead." } ] }, diff --git a/lib/gather-internals/walk-tree.js b/lib/gather-internals/walk-tree.js index c1cf0fe125..5f562a1b77 100644 --- a/lib/gather-internals/walk-tree.js +++ b/lib/gather-internals/walk-tree.js @@ -37,7 +37,7 @@ export function walkTree(tree = document.body) { // convert idref to node ancestry // aria props can use unattached nodes but those won't be used by the browser to calculate the prop value - if (value instanceof globalThis.HTMLElement) { + if (value instanceof globalThis.Node) { internals[prop] = value.isConnected ? { type: 'HTMLElement', value: getAncestry(value) } : undefined;