From 3514c77f7230dc0cbf5c3e220ef23827a0d4f0e7 Mon Sep 17 00:00:00 2001 From: Steven Lambert <2433219+straker@users.noreply.github.com> Date: Thu, 11 Jun 2026 09:29:28 -0600 Subject: [PATCH] fix(gather-internals): handle non-HTMLElement nodes --- eslint.config.js | 14 ++++++++++++++ lib/gather-internals/walk-tree.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) 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;