Skip to content

fix: stop corrupting the violations-by-node map in A11y - #5410

Open
zigzagdev wants to merge 2 commits into
uber:mainfrom
zigzagdev:fix/a11y-segment-violations-by-node
Open

fix: stop corrupting the violations-by-node map in A11y#5410
zigzagdev wants to merge 2 commits into
uber:mainfrom
zigzagdev:fix/a11y-segment-violations-by-node

Conversation

@zigzagdev

@zigzagdev zigzagdev commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Fixes

Description

segmentViolationsByNode builds a map from DOM node target to its axe violations.
When a node already had an entry, it work:

map[node.target] = map[node.target].push(violation);

Array.prototype.push returns the new length (a number), not the array, so this overwrote the array with a number. Once a node had 2 violations recorded, map[target] became a number instead of an array.
On a 3rd violation for that same node, map[target].push(...) threw a TypeError, crashing the dev-only A11y wrapper.

Scope

Patch: Bug Fix

…entries

Tracks the confirmed findings from the src/a11y..src/button review. The
accordion itemRefs/ArrowUp and badge LEFT_PLACEMENTS fixes already merged
to main, so their entries are removed here.
segmentViolationsByNode assigned Array.prototype.push's return value (the
new length, a number) back into the map instead of just pushing onto the
existing array. Once a DOM node had 2 violations, map[target] became a
number; a 3rd violation on that same node then called .push on a number
and threw a TypeError, crashing the dev-only A11y wrapper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant