Repository navigation
fix(template-no-unsupported-role-attributes): skip elements with a dynamic role - #2831
Merged
NullVoxPopuli merged 1 commit intoAug 2, 2026
Conversation
…namic role
An element carrying `role={{...}}` was treated as if it had no `role`
attribute at all, so the rule fell back to the element's implicit role and
judged every `aria-*` attribute against it. On top of the false positive, the
fixer then deleted those attributes:
<div role={{if @usecase "dialog"}} aria-modal={{if @usecase "true"}}></div>
reported `aria-modal is not supported by ... div with the implicit role of
generic` and `--fix` removed `aria-modal`.
ember-template-lint branches on the presence of the `role` attribute before
looking at its value, and reports nothing here. Restore that: a `role`
attribute with a non-static value means the role is unknowable, so the element
is skipped rather than falling through to the implicit role.
NullVoxPopuli
approved these changes
Aug 2, 2026
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.
Reported during an ember-template-lint → eslint-plugin-ember migration.
Problem
An element carrying a dynamic
rolewas treated as if it had noroleattribute at all. The rule fell back to the element's implicit role and judged everyaria-*attribute against it — and the fixer then deleted them.reported:
and
--fixrewrote it to<div role={{if @useCase "dialog"}}></div>, silently droppingaria-modal.ember-template-lintreports nothing here: it branches on the presence of theroleattribute before looking at its value, so a dynamic value leavesroleundefined and the element is skipped — it never falls through to the implicit role. The port collapsed those two branches into one, losing the distinction between "noroleattribute" and "roleattribute present but not statically resolvable".Fix
getExplicitRolenow distinguishes the three cases, and a dynamic role short-circuits the element instead of falling back to the implicit role.Verification
role={{this.role}},role="{{this.role}}",role={{if ...}}androle={{@role}}, in both.gjsand.hbsmode.ember-template-lint7.9.3 over 41,280 generatedrole/aria-*combinations (every non-abstractaria-queryrole × 8 host elements × 10 attribute-value forms × 6 aria probes): zero cases where upstream reports and this plugin stays silent. The remaining differences are the pre-existing deliberate ones — this plugin also normalizes whitespace-padded and uppercase role values.