Skip to content

Commit 7257fb6

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 87d7000 commit 7257fb6

5 files changed

Lines changed: 9 additions & 271 deletions

lib/rules/template-no-role-presentation-on-focusable.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
'use strict';
1717

1818
const { isComponentInvocation } = require('../utils/is-component-invocation');
19-
const { isNativeInteractive } = require('../utils/native-interactive-elements');
19+
const { isHtmlInteractiveContent } = require('../utils/html-interactive-content');
2020

2121
function findAttr(node, name) {
2222
return node.attributes?.find((a) => a.name === name);
@@ -49,7 +49,13 @@ function isFocusable(node) {
4949
if (findAttr(node, 'tabindex')) {
5050
return true;
5151
}
52-
return isNativeInteractive(node, getTextAttrValue);
52+
// <area href> is focusable (part of an image map's sequential focus order
53+
// per HTML §6.6.3) but is not HTML §3.2.5.2.7 interactive content, so the
54+
// shared util doesn't classify it. Rule-level special case.
55+
if (typeof node.tag === 'string' && node.tag.toLowerCase() === 'area') {
56+
return Boolean(findAttr(node, 'href'));
57+
}
58+
return isHtmlInteractiveContent(node, getTextAttrValue);
5359
}
5460

5561
/** @type {import('eslint').Rule.RuleModule} */

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 & 89 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)