Skip to content

Commit d653254

Browse files
committed
Avoid semantic IDs that are not in the tree
1 parent 729afb9 commit d653254

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

ts/a11y/explorer/KeyExplorer.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,15 +1070,14 @@ export class SpeechExplorer
10701070
const sub = this.subtrees.get(id);
10711071
const children: Set<string> = new Set();
10721072
for (const node of nodes) {
1073-
Array.from(node.querySelectorAll(`[data-semantic-id]`)).forEach((x) =>
1074-
children.add(x.getAttribute('data-semantic-id'))
1075-
);
1073+
(
1074+
Array.from(node.querySelectorAll(`[data-semantic-id]`)) as HTMLElement[]
1075+
).forEach((x) => children.add(this.nodeId(x)));
10761076
}
10771077
const rest = setdifference(sub, children);
1078-
return [...rest].map((child) => {
1079-
const node = this.node.querySelector(`[data-semantic-id="${child}"]`);
1080-
return node as HTMLElement;
1081-
});
1078+
return [...rest]
1079+
.map((child) => this.getNode(child))
1080+
.filter((node) => node !== null);
10821081
}
10831082

10841083
/**

0 commit comments

Comments
 (0)