Skip to content

Commit 6e45e37

Browse files
committed
fix(#19): address round-2 Copilot review (doc + test polish)
1 parent 7122c53 commit 6e45e37

4 files changed

Lines changed: 22 additions & 9 deletions

File tree

docs/rules/template-no-aria-hidden-on-focusable.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Per [WAI-ARIA 1.2 — aria-hidden](https://www.w3.org/TR/wai-aria-1.2/#aria-hidd
1212
1313
The phrase "may receive focus" is interpreted to include focusable descendants: `aria-hidden` cascades to hide the entire subtree from assistive tech, while any focusable descendant within that subtree remains reachable via Tab — landing keyboard users on AT-invisible content.
1414

15+
### What counts as `aria-hidden="true"`
16+
17+
Only explicit truthy values trigger the rule: `aria-hidden="true"`, `aria-hidden={{true}}`, `aria-hidden="{{true}}"`, and case-insensitive variants. Valueless `<div aria-hidden>` and `aria-hidden="false"` / `{{false}}` are NOT treated as hidden — the author's signal must be explicit. See the shared spec-divergence rationale in `template-no-invalid-interactive` for the broader reasoning on valueless `aria-hidden` handling across this plugin.
18+
1519
## Examples
1620

1721
This rule **forbids** the following:

lib/rules/template-no-aria-hidden-on-focusable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ module.exports = {
160160
meta: {
161161
type: 'problem',
162162
docs: {
163-
description: 'disallow aria-hidden="true" on focusable elements',
163+
description:
164+
'disallow aria-hidden="true" on focusable elements or on ancestors of focusable descendants',
164165
category: 'Accessibility',
165166
url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-no-aria-hidden-on-focusable.md',
166167
templateMode: 'both',

tests/lib/rules/template-no-aria-hidden-on-focusable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ ruleTester.run('template-no-aria-hidden-on-focusable', rule, {
5959
'<template><div aria-hidden="true"><span>Just text</span></div></template>',
6060
// Component descendants are opaque — conservatively not flagged.
6161
'<template><div aria-hidden="true"><Button>X</Button></div></template>',
62-
// No focusable descendants (alt-less img is decorative, not focusable).
62+
// <img> without usemap is non-focusable regardless of alt text.
6363
'<template><div aria-hidden="true"><img alt="static" /></div></template>',
6464
// <input type="hidden"> is non-focusable per isFocusable.
6565
'<template><div aria-hidden="true"><input type="hidden" /></div></template>',

tests/lib/utils/is-native-element-test.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,20 @@ describe('isNativeElement — list-only behavior (no sourceCode)', () => {
8080
});
8181

8282
describe('ELEMENT_TAGS', () => {
83-
it('includes all HTML, SVG, and MathML tag names', () => {
84-
// Sanity check — if this ever drops below a reasonable size, one of the
85-
// underlying packages has changed contract.
86-
expect(ELEMENT_TAGS.size).toBeGreaterThan(200);
87-
expect(ELEMENT_TAGS.has('div')).toBe(true);
88-
expect(ELEMENT_TAGS.has('circle')).toBe(true);
89-
expect(ELEMENT_TAGS.has('mfrac')).toBe(true);
83+
it('includes representative HTML, SVG, and MathML tag names', () => {
84+
// Spot-check one tag per source package rather than pinning a count,
85+
// which drifts whenever html-tags / svg-tags / mathml-tag-names ship
86+
// new entries.
87+
expect(ELEMENT_TAGS.has('div')).toBe(true); // html-tags
88+
expect(ELEMENT_TAGS.has('button')).toBe(true);
89+
expect(ELEMENT_TAGS.has('circle')).toBe(true); // svg-tags
90+
expect(ELEMENT_TAGS.has('path')).toBe(true);
91+
expect(ELEMENT_TAGS.has('mfrac')).toBe(true); // mathml-tag-names
92+
expect(ELEMENT_TAGS.has('msqrt')).toBe(true);
93+
});
94+
95+
it('excludes non-tags', () => {
96+
expect(ELEMENT_TAGS.has('MyComponent')).toBe(false);
97+
expect(ELEMENT_TAGS.has('my-widget')).toBe(false);
9098
});
9199
});

0 commit comments

Comments
 (0)