Visitar URL original
fix(target-size): ignore widget that is the only child of another widget by straker · Pull Request #5492 · dequelabs/axe-core · GitHub
Skip to content

fix(target-size): ignore widget that is the only child of another widget - #5492

Open
straker wants to merge 8 commits into
developfrom
only-child-widget
Open

straker wants to merge 8 commits into
developfrom
only-child-widget

Conversation

@straker

@straker straker commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Ignore a widget from the target-offset check if it's the only child of another widget. We're going to assume that if it doesn't fail nested-interactive then the parent widget and the child widget are the same target. This takes into account any wrapping elements as well so a span in between will still count them as only child.

To fix the target-size full integration test we decided to unnest the spans. I decided it was easier to flip the targets than try to match their position before. So instead of a small box on the left and a large box on the right, the large box is on the left and the small one on the right. I made sure that the relative positioning was still the same.

Before changes:

After changes:

Closes: #5184

@straker
straker requested a review from a team as a code owner October 21, 2026 15:05
Copilot AI balanced review requested due to automatic review settings October 21, 2026 15:05

Copilot AI left a comment

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.

🟡 Changes recommended

Default enablement exceeds the intended scope, and existing unit assertions conflict with the new behavior.

1 open issue
What changed in this PR

Updates target-size handling so a widget and its sole nested widget count as one target, including through wrapping elements.

Changes:

  • Adds sole-descendant detection to target comparison.
  • Adds unit and integration cases for nested widgets and sibling content.
  • Removes the rule’s default-disable flag.
File Description
test/​integration/​rules/​target-size/​target-size.json Adds expected nested-widget results.
test/​integration/​rules/​target-size/​target-size.html Adds nested-widget fixtures.
test/​commons/​dom/​is-separate-target.js Tests sole-child and sibling cases.
lib/​rules/​target-size.json Enables the rule by default.
lib/​commons/​dom/​is-separate-target.js Excludes sole nested widgets from separate targets.

Review effort: Balanced

Comment thread lib/commons/dom/is-separate-target.js Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Performance comparison

axe metric: 🟢 No significant regression (worst: /sites/very-large-page at +1.1% median, +175ms)

Base f86d978 vs head 3ae0263.

Site Cold start Median Max
/sites/mdn 1,421ms → 1,455ms (+2.4%) 1,205ms → 1,172ms (-2.7%) 1,350ms → 1,287ms (-4.7%)
/sites/very-large-page 16,670ms → 17,210ms (+3.2%) 16,555ms → 16,730ms (+1.1%) 16,925ms → 17,671ms (+4.4%)

per-metric regressions: (worst ms increases regardless of axe status)

  • /sites/very-large-page reporter: +130ms (+6.4%)

The performance comparison bot is just a rough check for spotting problems and is not authoritative. Just because something shows as being faster or slower than the current base does not mean it is true. All performance problems should be investigated manually.

Comment on lines -358 to -379
`<button style="margin:1px; line-height:20px">Play</button>` +
`</a>`
);
const out = check.evaluate.apply(checkContext, checkArgs);
assert.isFalse(out);
});

it('returns true if the widget is not tabbable', () => {
const checkArgs = checkSetup(
`<a role="link" aria-label="play" tabindex="0" style="display:inline-block" id="target">` +
`<button tabindex="-1" style="margin:1px; line-height:20px">Play</button>` +
`</a>`
);
const out = check.evaluate.apply(checkContext, checkArgs);
assert.isTrue(out);
});
});

describe('that is a descendant', () => {
it('returns false if the widget is tabbable', () => {
const checkArgs = checkSetup(
`<a role="link" aria-label="play" tabindex="0" style="display:inline-block" id="target">` +

@straker straker Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This appears to be a complete duplicate describe and tests of the previous one, so am just removing it.

@github-actions

Copy link
Copy Markdown
Contributor

Performance comparison

axe metric: 🟢 No significant regression (worst: /sites/mdn at -0.8% median, -14ms)

Base f86d978 vs head f57c698.

Site Cold start Median Max
/sites/mdn 2,152ms → 2,132ms (-0.9%) 1,727ms → 1,714ms (-0.8%) 1,873ms → 1,872ms (-0.1%)
/sites/very-large-page 25,563ms → 24,909ms (-2.6%) 24,295ms → 24,046ms (-1.0%) 25,829ms → 24,553ms (-4.9%)

The performance comparison bot is just a rough check for spotting problems and is not authoritative. Just because something shows as being faster or slower than the current base does not mean it is true. All performance problems should be investigated manually.

@straker

straker commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Drafting this until I can talk to Wilco about it. I don't want to go changing the integration test page without his input.

@straker
straker marked this pull request as draft October 21, 2026 17:11
@straker
straker marked this pull request as ready for review November 2, 2026 22:31
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Performance comparison

axe metric: 🟢 No significant regression (worst: /sites/mdn at +3.6% median, +50ms)

Base 6b52b84 vs head f63d010.

Site Cold start Median Max
/sites/mdn 1,748ms → 1,799ms (+2.9%) 1,358ms → 1,408ms (+3.6%) 1,499ms → 1,591ms (+6.1%)
/sites/very-large-page 19,751ms → 20,096ms (+1.7%) 19,903ms → 19,631ms (-1.4%) 20,249ms → 19,767ms (-2.4%)

The performance comparison bot is just a rough check for spotting problems and is not authoritative. Just because something shows as being faster or slower than the current base does not mean it is true. All performance problems should be investigated manually.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Performance comparison

axe metric: 🟢 No significant regression (worst: /sites/very-large-page at +0.5% median, +74ms)

Base 6b52b84 vs head 27e70b4.

Site Cold start Median Max
/sites/mdn 1,371ms → 1,414ms (+3.1%) 1,133ms → 1,119ms (-1.3%) 1,534ms → 1,298ms (-15.4%)
/sites/very-large-page 16,314ms → 17,304ms (+6.1%) 15,929ms → 16,003ms (+0.5%) 16,002ms → 16,218ms (+1.3%)

The performance comparison bot is just a rough check for spotting problems and is not authoritative. Just because something shows as being faster or slower than the current base does not mean it is true. All performance problems should be investigated manually.

This branch has not been deployed

No deployments
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.

Rethink how to handle a[href] > button cases

2 participants