Skip to content

Commit 9dd106d

Browse files
committed
fix(#48): address round-2 Copilot review (doc + test polish)
1 parent 00a5c40 commit 9dd106d

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function isAriaHiddenTruthy(attr) {
4040
return value.path.value === true;
4141
}
4242
if (value.path.type === 'GlimmerStringLiteral') {
43-
return value.path.value.toLowerCase() === 'true';
43+
return value.path.value.trim().toLowerCase() === 'true';
4444
}
4545
}
4646
if (value.type === 'GlimmerConcatStatement') {
@@ -58,11 +58,11 @@ function isAriaHiddenTruthy(attr) {
5858
return only.path.value === true;
5959
}
6060
if (only.path.type === 'GlimmerStringLiteral') {
61-
return only.path.value.toLowerCase() === 'true';
61+
return only.path.value.trim().toLowerCase() === 'true';
6262
}
6363
}
6464
if (only.type === 'GlimmerTextNode') {
65-
const chars = only.chars.toLowerCase();
65+
const chars = only.chars.trim().toLowerCase();
6666
return chars === '' || chars === 'true';
6767
}
6868
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ ruleTester.run('template-no-empty-headings', rule, {
5454
'<template><h1 aria-hidden="True"></h1></template>',
5555
'<template><h1 aria-hidden={{"TRUE"}}></h1></template>',
5656
'<template><h1 aria-hidden={{"True"}}></h1></template>',
57+
// Quoted-mustache (GlimmerConcatStatement) forms — `aria-hidden="{{true}}"`
58+
// resolves the same as `aria-hidden={{true}}`. Pin these so future
59+
// refactors don't regress concat handling.
60+
'<template><h1 aria-hidden="{{true}}"></h1></template>',
61+
'<template><h1 aria-hidden="{{"true"}}"></h1></template>',
62+
// Whitespace normalization — incidental surrounding whitespace should
63+
// still resolve to "true".
64+
'<template><h1 aria-hidden={{" true "}}></h1></template>',
65+
'<template><h1 aria-hidden=" true "></h1></template>',
5766
],
5867
invalid: [
5968
{

0 commit comments

Comments
 (0)