Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion lib/gather-internals/walk-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need to be Element? I tested it out, you can't assign text nodes to ariaLabelledbyElement. So that's good. In practice this shouldn't matter, so I think it's fine.

internals[prop] = value.isConnected
? { type: 'HTMLElement', value: getAncestry(value) }
: undefined;
Expand Down
Loading