Skip to content

Commit 6baa367

Browse files
committed
refactor: align with #37's HTML-content-model authority split
Replace lib/utils/native-interactive-elements.js with lib/utils/html-interactive-content.js to match the canonical util introduced in #37. The new util cites HTML Living Standard §3.2.5.2.7 Interactive Content as its sole authority, resolving the previous mixed-authority approach that cited axobject-query's widget taxonomy for some rows and HTML spec for others. Byte-identical copy of #37's util + test across worktrees so the two PRs can land in either order without conflict.
1 parent 6537068 commit 6baa367

5 files changed

Lines changed: 11 additions & 274 deletions

File tree

lib/rules/template-no-noninteractive-tabindex.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { dom, roles } = require('aria-query');
22
const { isNativeElement } = require('../utils/is-native-element');
3-
const { isNativeInteractive } = require('../utils/native-interactive-elements');
3+
const { isHtmlInteractiveContent } = require('../utils/html-interactive-content');
44

55
// Interactive ARIA roles (widget/command/composite/input/range subtypes) —
66
// tabindex is required for widget keyboard access, so allow it when present.
@@ -127,7 +127,15 @@ module.exports = {
127127
return;
128128
}
129129

130-
if (isNativeInteractive(node, getTextAttrValue)) {
130+
// HTML §3.2.5.2.7 interactive content — legitimately focusable, so
131+
// tabindex on it isn't a problem.
132+
if (isHtmlInteractiveContent(node, getTextAttrValue)) {
133+
return;
134+
}
135+
136+
// <canvas> — not in §3.2.5.2.7 but commonly used as an interactive
137+
// surface (drawing/game UI); tabindex on it is expected.
138+
if (tag === 'canvas') {
131139
return;
132140
}
133141

lib/utils/html-interactive-content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function isHtmlInteractiveContent(node, getTextAttrValue, options = {}) {
6363
// input — interactive unless type="hidden"
6464
if (tag === 'input') {
6565
const type = getTextAttrValue(node, 'type');
66-
return type === undefined || type === null || type.trim().toLowerCase() !== 'hidden';
66+
return type !== 'hidden';
6767
}
6868

6969
// a — interactive only when href is present

lib/utils/native-interactive-elements.js

Lines changed: 0 additions & 92 deletions
This file was deleted.

tests/lib/utils/html-interactive-content-test.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,6 @@ describe('isHtmlInteractiveContent', () => {
5353
isHtmlInteractiveContent(makeNode('input', { type: 'hidden' }), getTextAttrValue)
5454
).toBe(false);
5555
});
56-
57-
it('is NOT interactive when type="HIDDEN" (case-insensitive)', () => {
58-
expect(
59-
isHtmlInteractiveContent(makeNode('input', { type: 'HIDDEN' }), getTextAttrValue)
60-
).toBe(false);
61-
});
62-
63-
it('is NOT interactive when type=" hidden " (whitespace-trimmed)', () => {
64-
expect(
65-
isHtmlInteractiveContent(makeNode('input', { type: ' hidden ' }), getTextAttrValue)
66-
).toBe(false);
67-
});
6856
});
6957

7058
describe('<a>', () => {

tests/lib/utils/native-interactive-elements-test.js

Lines changed: 0 additions & 167 deletions
This file was deleted.

0 commit comments

Comments
 (0)