Skip to content

Commit 545ed9c

Browse files
committed
sync: interactive-roles to canonical (use strict added)
1 parent de54a70 commit 545ed9c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

lib/utils/interactive-roles.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
const { roles } = require('aria-query');
24

35
// Interactive ARIA roles — concrete roles whose taxonomy descends from `widget`
@@ -106,13 +108,17 @@ function buildCompositeWidgetChildren() {
106108
const out = new Set();
107109
const kids = direct.get(role);
108110
if (!kids) {
111+
closed.set(role, out);
109112
return out;
110113
}
111114
for (const child of kids) {
112115
out.add(child);
113116
if (!visited.has(child)) {
114-
visited.add(child);
115-
for (const grandchild of expand(child, visited)) {
117+
// Pass a fresh branch-specific visited set so sibling branches do not
118+
// contaminate each other's traversal. A shared Set across branches
119+
// makes memoized results order-dependent, because whether `child` is
120+
// recursed into depends on which sibling ran first.
121+
for (const grandchild of expand(child, new Set([...visited, child]))) {
116122
out.add(grandchild);
117123
}
118124
}

0 commit comments

Comments
 (0)