Skip to content

Commit 8a6332f

Browse files
committed
refactor: sync html-interactive-content util to canonical (Copilot review)
1 parent 80cec4c commit 8a6332f

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

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 !== 'hidden';
66+
return type === undefined || type === null || type.trim().toLowerCase() !== 'hidden';
6767
}
6868

6969
// a — interactive only when href is present

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ 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+
});
5668
});
5769

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

0 commit comments

Comments
 (0)