fix: template-no-invalid-interactive — honor role=presentation/none and aria-hidden#2754
Draft
johanrd wants to merge 2 commits intoember-cli:masterfrom
Draft
fix: template-no-invalid-interactive — honor role=presentation/none and aria-hidden#2754johanrd wants to merge 2 commits intoember-cli:masterfrom
johanrd wants to merge 2 commits intoember-cli:masterfrom
Conversation
…en caveat in docs, fix isPresentationRole filename refs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This is part of a series where Claude has audited
eslint-plugin-emberagainst jsx-a11y, vuejs-accessibility, angular-eslint, lit-a11y and html-validate,ember-template-lint, and the HTML and WCAG specs.Premise
Peer accessibility plugins honor two ARIA signals as opt-outs of the "interactive handler on non-interactive element" check:
isPresentationRole()short-circuitsno-static-element-interactionsandno-noninteractive-element-interactions. Separately,isHiddenFromScreenReader()handlesaria-hidden.no-static-element-interactionsacceptsrole=\"presentation\"andaria-hidden=\"true\"on clickable elements as VALID.Flagging these is a false positive.
template-no-invalid-interactivenow short-circuits on an explicit opt-out before the native/role-based interactivity probe runs.Helper —
hasNonInteractiveEscapeHatch(node)Returns true iff the element carries any of:
role=\"presentation\"orrole=\"none\"— case-insensitive, trimmed, first token of a space-separated role list. (Note: jsx-a11y'sisPresentationRoledoes plain exact-match — our first-token handling is a deliberate superset, matching ARIA 1.2 §5.4 role-fallback semantics.)aria-hiddenin any plausibly-"hide" form — valueless, empty,\"true\"(case-insensitive),{{true}},{{\"true\"}}.Explicit
aria-hidden=\"false\"/{{false}}still flags — it's the unambiguous opt-in.Four ecosystem positions on valueless aria-hidden
The question "what does
<div aria-hidden>(bare),aria-hidden=\"\"(empty), oraria-hidden={{false}}mean?" has no single authoritative answer. Four defensible positions exist:jsx-ast-utilscoercing valueless JSX attrs to booleantrue. Quirk: stringaria-hidden=\"true\"is NOT recognized because\"true\" !== true. Not a deliberate ARIA interpretation.\"false\"→ hiddenisHiddenFromScreenReader.ts:(value || \"\").toString() !== \"false\". Non-spec shortcut.undefined→ not hiddentrue/false/undefined (default). Missing/empty resolves to default.Design choice
This rule leans toward fewer false positives. For this rule, that means treating valueless / empty
aria-hiddenas an escape hatch — flagging a click handler on an author-decorated element creates friction more often than it catches a real bug. The author wrotearia-hiddenfor a reason; trust the signal.Prior art
no-static-element-interactions/no-noninteractive-element-interactionsisPresentationRole()andisHiddenFromScreenReader()before the static-element check.no-static-element-interactionsrole=\"presentation\"andaria-hidden=\"true\"on clickable elements as VALID.click-events-have-key-eventsisPresentationRole(node)andisHiddenFromScreenReader(node)before the click-handler check.no-static-element-interactions-style rule;click-events-have-key-events.jsdoes not honorrole=\"presentation\"oraria-hidden.Tests
16 new valid cases (presentation / none + every plausibly-"hide" aria-hidden form); 3 new invalid cases confirming
aria-hidden=\"false\"/{{false}}are NOT opt-outs.