Skip to content

Commit 4544f39

Browse files
committed
fix(template-no-empty-headings): treat aria-hidden values case-insensitively
HTML attribute value comparison is ASCII case-insensitive per spec, so `aria-hidden="TRUE"` and `aria-hidden="True"` (and their mustache-string equivalents) should be recognised as truthy. Mirrors the same case- handling choice made in #2718 for `kind="captions"`. Tests cover `"TRUE"`, `"True"`, `{{"TRUE"}}`, `{{"True"}}`.
1 parent 2529828 commit 4544f39

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

lib/rules/template-no-empty-headings.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ function isAriaHiddenTruthy(attr) {
1010
if (!value || (value.type === 'GlimmerTextNode' && value.chars === '')) {
1111
return true;
1212
}
13+
// HTML attribute values compare ASCII-case-insensitively, so "TRUE"/"True"
14+
// count as truthy.
1315
if (value.type === 'GlimmerTextNode') {
14-
return value.chars === 'true';
16+
return value.chars.toLowerCase() === 'true';
1517
}
1618
if (value.type === 'GlimmerMustacheStatement' && value.path) {
1719
if (value.path.type === 'GlimmerBooleanLiteral') {
1820
return value.path.value === true;
1921
}
2022
if (value.path.type === 'GlimmerStringLiteral') {
21-
return value.path.value === 'true';
23+
return value.path.value.toLowerCase() === 'true';
2224
}
2325
}
2426
return false;

tests/lib/rules/template-no-empty-headings.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ ruleTester.run('template-no-empty-headings', rule, {
5151
'<template><h1 aria-hidden=""></h1></template>',
5252
'<template><h1 aria-hidden={{true}}></h1></template>',
5353
'<template><h1 aria-hidden="true">Visible to sighted only</h1></template>',
54+
55+
// HTML attribute values are ASCII case-insensitive — "TRUE" / "True" /
56+
// {{"TRUE"}} / {{"True"}} all count as truthy.
57+
'<template><h1 aria-hidden="TRUE"></h1></template>',
58+
'<template><h1 aria-hidden="True"></h1></template>',
59+
'<template><h1 aria-hidden={{"TRUE"}}></h1></template>',
60+
'<template><h1 aria-hidden={{"True"}}></h1></template>',
5461
],
5562
invalid: [
5663
{

0 commit comments

Comments
 (0)