Skip to content

feat: add template-click-events-have-key-events#17

Open
johanrd wants to merge 19 commits intomasterfrom
feat/template-click-events-have-key-events
Open

feat: add template-click-events-have-key-events#17
johanrd wants to merge 19 commits intomasterfrom
feat/template-click-events-have-key-events

Conversation

@johanrd
Copy link
Copy Markdown
Owner

@johanrd johanrd commented Apr 21, 2026

Note

This is part of a series where Claude has audited eslint-plugin-ember against jsx-a11y, vuejs-accessibility, angular-eslint, lit-a11y and html-validate, ember-template-lint, and the HTML and WCAG specs.

  • Premise 1: A non-interactive element wired only to click events violates WCAG 2.1 SC 2.1.1 Keyboard (Level A) in practice — keyboard-only users can't reach the handler. Strictly, SC 2.1.1 accepts any keyboard path (Understanding 2.1.1 notes "Enter only" counts), so the click+keydown pairing this rule checks is a peer-plugin convention (jsx-a11y / vuejs-accessibility / lit-a11y / @angular-eslint/template all use it) as the strongest static-analysis proxy — not a literal SC-mandated pairing.
  • Premise 2: This concept is covered by all four peer a11y plugins (verified in source — see Prior art) but not by our plugin today. Our existing template-no-invalid-interactive takes a stricter stance ("don't use {{on "click"}} on non-interactive elements at all"); this rule is the softer, more permissive check.
  • Conclusion: Add a new rule template-click-events-have-key-events that flags a non-interactive DOM element with {{on "click" …}} when no {{on "keydown" …}} / {{on "keyup" …}} / {{on "keypress" …}} modifier is present.

Flags

<div {{on "click" this.onClick}}></div>
<span {{on "click" this.onClick}}>text</span>
<a {{on "click" this.onClick}}>Not a link</a>   {{! <a> without href is non-interactive }}

Allows

<button {{on "click" this.onClick}}>Toggle</button>
<div role="presentation" {{on "click" this.onClick}}></div>   {{! explicit decorative }}
<div {{on "click" this.onClick}} {{on "keydown" this.onKeydown}}></div>

The rule exempts elements carrying role="presentation" / role="none" and aria-hidden via hasPresentationRole-style handling. It does not separately walk interactive ARIA roles (role="button", role="link", etc.) — in practice those cases are handled upstream by template-no-invalid-interactive.

Prior art

Verified each peer in source:

Plugin File Notes
jsx-a11y click-events-have-key-events.js:22-69 Canonical reference
vuejs-accessibility click-events-have-key-events.ts:14-42 Same logic; uses shared isInteractiveElement/isPresentationRole utils
lit-a11y click-events-have-key-events.js:19-109 Adds allowList / allowCustomElements options; uses isNonInteractiveElement
@angular-eslint/template click-events-have-key-events.ts:22-101 Only checks role === 'button'; acknowledged TODO at line 69 to extend to all interactive roles

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

🏎️ Benchmark Comparison

Benchmark Control (p50) Experiment (p50) Δ
js small 12.35 ms 12.20 ms -1.2%
js medium 6.01 ms 5.92 ms -1.4%
🟠 js large 2.25 ms 2.34 ms +3.6%
gjs small 1.17 ms 1.16 ms -0.8%
gjs medium 583.80 µs 582.33 µs -0.3%
gjs large 228.34 µs 228.12 µs -0.1%
gts small 1.15 ms 1.15 ms +0.5%
gts medium 579.57 µs 579.20 µs -0.1%
gts large 229.85 µs 228.64 µs -0.5%

🟢 faster · 🔴 slower · 🟠 slightly slower · ⚪ within 2%

Full mitata output
clk: ~3.33 GHz
cpu: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz
runtime: node 24.15.0 (x64-linux)

benchmark                   avg (min … max) p75 / p99    (min … top 1%)
------------------------------------------- -------------------------------
js small (control)            14.83 ms/iter  15.93 ms █ ▅                  
                      (10.45 ms … 29.19 ms)  26.14 ms █▃█  ▃               
                    (  5.46 mb …  10.62 mb)   7.20 mb ███▆▄█▆█▄▁▁▁▄▁▁▄▁▆▆▁▄

js small (experiment)         12.84 ms/iter  13.77 ms ▂ █                  
                      (10.87 ms … 17.99 ms)  17.93 ms █▅█▅▅▅▅ ▂ ▂▂         
                    (  6.21 mb …   8.29 mb)   6.83 mb ███████▁█▁██▄▁▁▁▄▁▁▄▄

                             ┌                                            ┐
                             ╷┌───────────┬──┐                            ╷
          js small (control) ├┤           │  ├────────────────────────────┤
                             ╵└───────────┴──┘                            ╵
                              ╷ ┌───┬──┐          ╷
       js small (experiment)  ├─┤   │  ├──────────┤
                              ╵ └───┴──┘          ╵
                             └                                            ┘
                             10.45 ms           18.30 ms           26.14 ms

summary
  js small (experiment)
   1.15x faster than js small (control)

------------------------------------------- -------------------------------
js medium (control)            6.80 ms/iter   7.14 ms  █                   
                       (5.59 ms … 13.18 ms)  12.11 ms  █                   
                    (  2.43 mb …   4.61 mb)   3.53 mb ██▇▃▂▄▂▂▂▃▃▃▂▁▂▂▂▁▁▁▂

js medium (experiment)         6.61 ms/iter   6.80 ms  █                   
                       (5.61 ms … 12.21 ms)  11.74 ms ▆█                   
                    (  3.20 mb …   4.76 mb)   3.53 mb ██▄▃▄▃▃▃▂▃▂▁▂▁▂▂▁▁▂▂▂

                             ┌                                            ┐
                             ╷ ┌─────┬──┐                                 ╷
         js medium (control) ├─┤     │  ├─────────────────────────────────┤
                             ╵ └─────┴──┘                                 ╵
                             ╷┌─────┬┐                                 ╷
      js medium (experiment) ├┤     │├─────────────────────────────────┤
                             ╵└─────┴┘                                 ╵
                             └                                            ┘
                             5.59 ms            8.85 ms            12.11 ms

summary
  js medium (experiment)
   1.03x faster than js medium (control)

------------------------------------------- -------------------------------
js large (control)             2.72 ms/iter   2.61 ms █▅                   
                        (2.10 ms … 9.23 ms)   6.84 ms ██                   
                    (190.86 kb …   3.03 mb)   1.43 mb ██▄▄▁▃▂▂▂▁▁▁▂▁▁▁▁▁▁▁▁

js large (experiment)          2.61 ms/iter   2.44 ms  █                   
                        (2.22 ms … 6.55 ms)   5.38 ms ██                   
                    (355.50 kb …   2.52 mb)   1.43 mb ██▃▂▂▂▂▁▃▁▁▂▁▁▁▁▁▁▁▁▂

                             ┌                                            ┐
                             ╷┌────┬                                      ╷
          js large (control) ├┤    │──────────────────────────────────────┤
                             ╵└────┴                                      ╵
                              ╷┌──┬                         ╷
       js large (experiment)  ├┤  │─────────────────────────┤
                              ╵└──┴                         ╵
                             └                                            ┘
                             2.10 ms            4.47 ms             6.84 ms

summary
  js large (experiment)
   1.04x faster than js large (control)

------------------------------------------- -------------------------------
gjs small (control)            1.29 ms/iter   1.20 ms █                    
                        (1.14 ms … 5.83 ms)   5.12 ms █                    
                    (604.07 kb …   1.67 mb)   1.06 mb █▄▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gjs small (experiment)         1.28 ms/iter   1.19 ms █                    
                        (1.13 ms … 5.81 ms)   5.11 ms █                    
                    (479.90 kb …   1.66 mb)   1.06 mb █▄▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌─┬                                          ╷
         gjs small (control) │ │──────────────────────────────────────────┤
                             └─┴                                          ╵
                             ┌─┬                                          ╷
      gjs small (experiment) │ │──────────────────────────────────────────┤
                             └─┴                                          ╵
                             └                                            ┘
                             1.13 ms            3.12 ms             5.12 ms

summary
  gjs small (experiment)
   1.01x faster than gjs small (control)

------------------------------------------- -------------------------------
gjs medium (control)         638.22 µs/iter 595.00 µs █                    
                      (558.94 µs … 5.75 ms)   3.01 ms █                    
                    ( 79.24 kb …   1.13 mb) 540.81 kb █▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gjs medium (experiment)      663.83 µs/iter 611.20 µs █▄                   
                      (555.71 µs … 6.89 ms)   1.52 ms ██                   
                    ( 86.64 kb …   1.04 mb) 540.75 kb ██▄▂▃▂▃▂▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌─┬                                          ╷
        gjs medium (control) │ │──────────────────────────────────────────┤
                             └─┴                                          ╵
                             ┌─┬               ╷
     gjs medium (experiment) │ │───────────────┤
                             └─┴               ╵
                             └                                            ┘
                             555.71 µs           1.78 ms            3.01 ms

summary
  gjs medium (control)
   1.04x faster than gjs medium (experiment)

------------------------------------------- -------------------------------
gjs large (control)          250.07 µs/iter 237.72 µs  █                   
                      (220.62 µs … 4.88 ms) 288.24 µs  █▅▃                 
                    ( 17.61 kb … 966.72 kb) 217.19 kb ▃███▄▄▅▆▄▂▂▁▁▁▁▁▁▁▁▁▁

gjs large (experiment)       249.04 µs/iter 237.59 µs  █                   
                      (220.22 µs … 4.93 ms) 285.83 µs  █▆▄                 
                    (170.17 kb … 801.94 kb) 216.46 kb ▅███▆▄▆▆▄▃▂▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ╷  ┌────────────────┬                        ╷
         gjs large (control) ├──┤                │────────────────────────┤
                             ╵  └────────────────┴                        ╵
                             ╷ ┌────────────────┬                       ╷
      gjs large (experiment) ├─┤                │───────────────────────┤
                             ╵ └────────────────┴                       ╵
                             └                                            ┘
                             220.22 µs         254.23 µs          288.24 µs

summary
  gjs large (experiment)
   1x faster than gjs large (control)

------------------------------------------- -------------------------------
gts small (control)            1.24 ms/iter   1.17 ms █                    
                        (1.13 ms … 5.75 ms)   5.07 ms █                    
                    (352.72 kb …   1.78 mb)   1.06 mb █▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gts small (experiment)         1.25 ms/iter   1.17 ms █                    
                        (1.13 ms … 6.09 ms)   5.62 ms █                    
                    (220.22 kb …   1.78 mb)   1.05 mb █▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌┬                                     ╷
         gts small (control) ││─────────────────────────────────────┤
                             └┴                                     ╵
                             ┌┬                                           ╷
      gts small (experiment) ││───────────────────────────────────────────┤
                             └┴                                           ╵
                             └                                            ┘
                             1.13 ms            3.37 ms             5.62 ms

summary
  gts small (control)
   1.01x faster than gts small (experiment)

------------------------------------------- -------------------------------
gts medium (control)         625.08 µs/iter 592.26 µs  █                   
                      (554.82 µs … 5.51 ms)   1.07 ms  █                   
                    (421.10 kb …   1.26 mb) 542.34 kb ██▇▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gts medium (experiment)      622.66 µs/iter 589.39 µs  █                   
                      (555.59 µs … 5.38 ms)   1.19 ms ▄█                   
                    (191.77 kb …   1.10 mb) 540.46 kb ██▄▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ╷┌───┬                               ╷
        gts medium (control) ├┤   │───────────────────────────────┤
                             ╵└───┴                               ╵
                             ╷┌───┬                                       ╷
     gts medium (experiment) ├┤   │───────────────────────────────────────┤
                             ╵└───┴                                       ╵
                             └                                            ┘
                             554.82 µs          873.13 µs           1.19 ms

summary
  gts medium (experiment)
   1x faster than gts medium (control)

------------------------------------------- -------------------------------
gts large (control)          252.48 µs/iter 240.50 µs  █                   
                      (222.71 µs … 5.03 ms) 300.91 µs  ██                  
                    (143.80 kb … 901.48 kb) 216.96 kb ▇██▅▄▆▇▄▂▁▁▁▁▁▁▁▁▁▁▁▁

gts large (experiment)       250.95 µs/iter 238.26 µs  █▄                  
                      (220.83 µs … 4.93 ms) 288.92 µs  ██▃                 
                    (170.19 kb …   1.30 mb) 216.61 kb ▃███▅▄▇▆▄▂▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                              ╷ ┌──────────────┬                          ╷
         gts large (control)  ├─┤              │──────────────────────────┤
                              ╵ └──────────────┴                          ╵
                             ╷ ┌──────────────┬                    ╷
      gts large (experiment) ├─┤              │────────────────────┤
                             ╵ └──────────────┴                    ╵
                             └                                            ┘
                             220.83 µs         260.87 µs          300.91 µs

summary
  gts large (experiment)
   1.01x faster than gts large (control)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new accessibility rule to enforce keyboard parity when non-interactive template elements use {{on "click" …}}, aligning behavior with peer a11y plugins.

Changes:

  • Introduces ember/template-click-events-have-key-events rule with exemptions for presentation/hidden cases and inherently interactive HTML.
  • Adds supporting utilities (isComponentInvocation, isHtmlInteractiveContent) with dedicated unit tests.
  • Documents the new rule and lists it in the README rules table; includes a peer-parity audit fixture.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/lib/utils/is-component-invocation-test.js Adds test coverage for component-invocation tag detection.
tests/lib/utils/html-interactive-content-test.js Adds spec-oriented tests for HTML “interactive content” classification.
tests/lib/rules/template-click-events-have-key-events.js Adds primary RuleTester coverage for the new rule in GJS/GTS + HBS modes.
tests/audit/click-events-have-key-events/peer-parity.js Adds an audit/peer-parity fixture for comparing behavior against other plugins.
lib/utils/is-component-invocation.js Adds helper to distinguish component invocations from native DOM tags.
lib/utils/html-interactive-content.js Adds helper for HTML interactive-content classification used by rules.
lib/rules/template-click-events-have-key-events.js Implements the new rule logic (click requires key handler on non-interactive DOM elements).
docs/rules/template-click-events-have-key-events.md Adds end-user documentation and examples for the new rule.
README.md Adds the new rule to the auto-generated rules list table.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/utils/is-component-invocation.js Outdated
Comment thread lib/utils/html-interactive-content.js Outdated
Comment thread tests/audit/click-events-have-key-events/peer-parity.js Outdated
Comment thread docs/rules/template-click-events-have-key-events.md Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rules/template-click-events-have-key-events.js
Comment thread lib/rules/template-click-events-have-key-events.js
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rules/template-click-events-have-key-events.js
Comment thread lib/rules/template-click-events-have-key-events.js
Comment thread lib/utils/is-native-element.js
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@johanrd johanrd requested a review from Copilot April 24, 2026 18:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@johanrd johanrd force-pushed the feat/template-click-events-have-key-events branch from aaa3605 to 8e4d319 Compare April 26, 2026 08:10
@johanrd johanrd requested a review from Copilot April 26, 2026 08:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@johanrd johanrd requested a review from Copilot April 27, 2026 11:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rules/template-click-events-have-key-events.js Outdated
Comment thread tests/lib/rules/template-click-events-have-key-events.js Outdated
@johanrd johanrd force-pushed the feat/template-click-events-have-key-events branch from 259835d to 432ba40 Compare April 27, 2026 14:00
@johanrd johanrd force-pushed the feat/template-click-events-have-key-events branch from 432ba40 to 0e728eb Compare April 27, 2026 19:26
@johanrd johanrd requested a review from Copilot April 27, 2026 19:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rules/template-click-events-have-key-events.js
schema: [],
messages: {
needsKeyEvent:
'Visible, non-interactive elements with click handlers must have at least one keyboard listener (keydown/keyup/keypress).',
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

The needsKeyEvent message starts with "Visible," but this rule doesn’t (and can’t) determine visual visibility; it only skips based on aria-hidden, hidden, and presentation roles. Consider rewording the message to avoid implying a visibility check (e.g., refer to "non-hidden" or just "non-interactive elements with click handlers").

Suggested change
'Visible, non-interactive elements with click handlers must have at least one keyboard listener (keydown/keyup/keypress).',
'Non-interactive elements with click handlers must have at least one keyboard listener (keydown/keyup/keypress).',

Copilot uses AI. Check for mistakes.
// Hidden from AT.
'<template><div aria-hidden="true" {{on "click" this.noop}}></div></template>',
// Mustache-literal boolean `true` — explicit static opt-out.
'<template><div aria-hidden={{true}} {{on "click" this.noop}}></div></template>',
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

Test coverage gap: there are valid cases for aria-hidden="true" and aria-hidden={{true}}, but no cases for other static equivalents already used elsewhere in the repo (e.g. aria-hidden={{"TRUE"}} and aria-hidden="{{true}}" / other GlimmerConcatStatement shapes). Adding these would prevent regressions in the rule’s aria-hidden exemption logic.

Suggested change
'<template><div aria-hidden={{true}} {{on "click" this.noop}}></div></template>',
'<template><div aria-hidden={{true}} {{on "click" this.noop}}></div></template>',
// Static string literal equivalents should also exempt.
'<template><div aria-hidden={{"TRUE"}} {{on "click" this.noop}}></div></template>',
'<template><div aria-hidden="{{true}}" {{on "click" this.noop}}></div></template>',

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +28
'<template><summary {{on "click" this.noop}}>More</summary></template>',
'<template><option {{on "click" this.h}}>Foo</option></template>',
'<template><datalist {{on "click" this.h}}></datalist></template>',

Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

The comment grouping <option> and <datalist> under “Inherently-interactive elements — keyboard is already built in” is misleading: those elements aren’t inherently keyboard-activatable on their own (and the rule exempts them via special-casing later). Consider adjusting the comment to reflect that these are explicit exemptions rather than native interactive controls.

Copilot uses AI. Check for mistakes.
NullVoxPopuli and others added 16 commits April 27, 2026 21:47
…-require-input-type

feat: add template-require-input-type
Captures empirically-verified Glimmer rendering behavior for HTML
attributes with mustache values, so rule authors classifying
GlimmerBooleanLiteral / GlimmerStringLiteral / GlimmerConcatStatement
have a ground-truth reference instead of intuition.

Notable findings the doc pins down:
- attr={{"false"}} (bare string "false") renders as attr="false" — TRUTHY,
  not falsy as the literal suggests.
- attr="{{false}}" (concat) sets the IDL property to true regardless of
  the literal value inside, even when HTML serialization shows nothing.
  Verified against <video muted="{{false}}"> → videoEl.muted === true.
- Non-reflecting boolean attrs (muted, autoplay) and reflecting ones
  (disabled, hidden) diverge in HTML serialization but agree at the IDL
  property layer.

Includes a copy-pasteable reproduction template so future readers can
re-verify if Glimmer behavior changes.

Adds a pointer in README's "Creating a New Rule" section.
Replaces the prior tables (which mixed verified data with extrapolations
marked "(assumed)") with strictly-verified per-attribute tables. Every cell
populated from rendering and IDL inspection in ember-source 6.12.

Structure:
- One "Reference table" section, five per-attribute sub-tables
  (muted, disabled, aria-hidden, tabindex, autocomplete)
- One "To reproduce the reference table" section with the exact template
  and JS console snippet, inline (no separate fixture file)
- Cross-attribute observations summarizing the rules the data reveals

Findings the new tables make explicit:
- Bare-mustache falsy set is {{false}}/{{null}}/{{undefined}}/{{0}} for
  boolean-coerced attrs (boolean HTML, ARIA, numeric); {{""}} is kept as
  attr="".
- Bare-mustache string literals never coerce — attr={{"false"}} renders
  as attr="false".
- Concat-mustache for boolean HTML attrs sets the IDL property to true
  regardless of the literal value inside (verified for both reflecting
  and non-reflecting attrs).
- Concat-mustache for ARIA/string attrs renders the stringified value
  literally — no boolean coercion. aria-hidden="{{false}}" is visible.
- Plain string attrs (autocomplete) skip Glimmer's boolean coercion
  entirely; autocomplete={{false}} renders as autocomplete="false".

The video.muted snapshot reads IDL muted=false for static attribute forms
(m1-m4, m7-m8, m11) because the test runs before media load — the doc
explains how defaultMuted reflects to muted at load time, so the rule's
"At play time" column is the lint-truth column rule authors should use.
…les" guide

Adds a practical-implementation section between the reference table and
the reproduction template. It maps each AST shape (GlimmerTextNode /
GlimmerMustacheStatement with each path type / GlimmerConcatStatement)
to a verdict, citing the row IDs from the reference table so rule
authors can implement classification correctly without re-deriving the
model.

Includes:
- AST-shape verdict table — direct mapping rule authors can copy from
- Six common mistakes section, each tied to specific row IDs
- Pointer to the (forthcoming) lib/utils/glimmer-attr-presence.js
  utility that will encode the verdict table once and let rules consume
  the resolved kind + value rather than re-walking the AST

The audit of master rules and the open feature PRs found 18 REAL_BUG
findings (12 in PRs, 6 in master) — all classifiable into the bullet-1
through bullet-4 footguns this guide enumerates.
…ng model

Adds lib/utils/glimmer-attr-presence.js exporting:

- classifyAttribute(attrNode, options?) → { presence, value }
  Maps every AST shape (valueless / GlimmerTextNode / GlimmerMustacheStatement
  with each path type / GlimmerConcatStatement) to a (presence, value) pair
  per the verified model in docs/glimmer-attribute-behavior.md. Each branch
  cites the relevant doc row IDs (m1–m19, h1–h15, d1–d10, t1–t7, i1–i5).
- inferAttrKind(name) → 'boolean' | 'aria' | 'numeric' | 'plain-string'
  Used when classifyAttribute callers don't pass options.kind explicitly.
- BOOLEAN_HTML_ATTRS, NUMERIC_ATTRS — exported sets, useful for callers
  that want to extend the kind model.

Key empirical asymmetries this util encodes correctly (and that audit
findings show several rules currently misclassify):

- Bare {{false}} / {{null}} / {{undefined}} on falsy-coerced kinds
  (boolean / aria / numeric) → presence='absent' (Glimmer omits attribute).
  Same forms on plain-string → presence='present', value='false' / etc.
- Bare {{"false"}} (StringLiteral) is JS-truthy, never coerced — renders
  the literal value across all attribute kinds.
- aria-hidden={{true}} renders aria-hidden="" (h5, contested), not
  aria-hidden="true" — the util surfaces value='' here so callers
  comparing value === 'true' don't false-match.
- Concat is never falsy: any concat form is presence='present'; the
  resolved value comes from the existing getStaticAttrValue helper.

Tests: 35 unit tests covering every doc row + the kind-override option.

Updates docs/glimmer-attribute-behavior.md to reference the actual file
and replaces the "(forthcoming)" sketch with a working example.
…ation / html-void-elements

Correctness fixes from PR ember-cli#2769 review:

- Boolean concat now returns canonical `value: 'true'` instead of leaking
  the inner literal. Per doc rows m13-m19, d7-d10 the IDL is set true
  regardless of inner value, so callers checking `value === 'false'` to
  detect "off" no longer get a wrong answer for `<video muted="{{false}}">`.
- {{true}} on numeric / plain-string now returns `unknown` (untested in
  doc; was previously claiming `value: 'true'` by extrapolation).
- `inferAttrKind` is now case-insensitive (`Disabled`, `ARIA-Hidden`, etc.).

Drop hand-rolled spec lists in favor of upstream packages:

- `property-information` for boolean / overloadedBoolean / number attribute
  classification, replacing the 24-entry BOOLEAN_HTML_ATTRS and 3-entry
  NUMERIC_ATTRS Sets. `colspan` is added as a small NUMERIC_OVERRIDES Set
  to compensate for an upstream gap in property-information 7.1.0 (rowspan
  and cols are marked `number: true`, colspan isn't).
- `html-void-elements` in template-block-indentation.js and
  template-self-closing-void-elements.js, deduplicating two parallel
  16-entry VOID_TAGS Sets.

Internal API change: BOOLEAN_HTML_ATTRS and NUMERIC_ATTRS are no longer
exported from glimmer-attr-presence. The util's public surface is now
`classifyAttribute` and `inferAttrKind`. Callers wanting the underlying
classification can use property-information directly.
…oss-attr m6/d3 analog)

`controls` on `<audio>`/`<video>` is an HTML boolean attribute, so per the
cross-attribute observation in docs/glimmer-attribute-behavior.md, bare
`{{false}}` / `{{null}}` / `{{undefined}}` cause Glimmer to omit the
attribute at runtime. The helper's previous AST-presence check
(hasAttribute) treated `<video controls={{false}}>` as still having
controls — a false positive that propagated to every rule using
isHtmlInteractiveContent: nested-interactive, no-noninteractive-tabindex,
interactive-supports-focus, click-events-have-key-events, etc.

After:
- `controls` flows through classifyAttribute. Bare-mustache falsy literals
  now correctly classify as 'absent' → element is NOT interactive at
  runtime.
- `href` and `usemap` continue to use AST-presence — those are plain
  string attributes that don't falsy-coerce (i4 analog: bare `{{false}}`
  on a plain string renders as the literal `"false"`, attribute kept).

Concat forms (`controls="{{X}}"`) still classify as 'present' because
concat is never falsy at runtime — so the existing pass-through behavior
for concat is preserved.

Tests:
- New: `<video controls={{false}}>` → not interactive (regression-locking).
- New: `<audio controls={{null}}>` → not interactive.
- New: `<video controls="{{false}}">` → IS interactive (concat sets IDL
  true regardless of inner literal).
- All 9555 existing tests pass — no rule was relying on the buggy
  behavior, so this fix lands cleanly across all consumers.
… message word; add aria-hidden mustache-string and concat tests; clarify option/datalist comment
@johanrd johanrd force-pushed the feat/template-click-events-have-key-events branch from a51c130 to 03ddced Compare April 28, 2026 12:37
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.

3 participants