Skip to content

Commit 634af79

Browse files
committed
refactor(template-require-iframe-title): remove allowWhitespaceOnlyTitle option
Whitespace-only titles are never intentional and the option added API surface with no real-world use case. Always flag empty/whitespace title values as errors.
1 parent 19e44c4 commit 634af79

3 files changed

Lines changed: 2 additions & 63 deletions

File tree

docs/rules/template-require-iframe-title.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,6 @@ This rule **forbids** the following:
3838
</template>
3939
```
4040

41-
Whitespace-only `title` (`" "`) is flagged by default as an
42-
authoring-hygiene check: HTML and ACCNAME technically permit it (step 2I
43-
doesn't trim), but a whitespace-only accessible name is useless in
44-
practice. Suppress this specific strictness via
45-
`allowWhitespaceOnlyTitle: true` if your codebase needs it.
46-
47-
## Configuration
48-
49-
- `allowWhitespaceOnlyTitle` (`boolean`, default `false`): when `true`,
50-
`<iframe title=" ">` is accepted. Empty-string `title=""` and
51-
non-string mustache literals (`{{null}}`, `{{undefined}}`, `{{42}}`) are
52-
still flagged.
53-
54-
```js
55-
module.exports = {
56-
rules: {
57-
'ember/template-require-iframe-title': ['error', { allowWhitespaceOnlyTitle: true }],
58-
},
59-
};
60-
```
61-
6241
## References
6342

6443
- [WCAG SC 4.1.2 — Name, Role, Value](https://www.w3.org/TR/UNDERSTANDING-WCAG20/ensure-compat-rsv.html)

lib/rules/template-require-iframe-title.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,7 @@ module.exports = {
4949
templateMode: 'both',
5050
},
5151
fixable: null,
52-
schema: [
53-
{
54-
type: 'object',
55-
properties: {
56-
allowWhitespaceOnlyTitle: {
57-
type: 'boolean',
58-
},
59-
},
60-
additionalProperties: false,
61-
},
62-
],
52+
schema: [],
6353
messages: {
6454
// Five messageIds (missingTitle, emptyTitle, invalidTitleLiteral,
6555
// duplicateTitleFirst, duplicateTitleOther) for richer diagnostic detail.
@@ -79,14 +69,6 @@ module.exports = {
7969
},
8070
},
8171
create(context) {
82-
// Whitespace-only `title=" "` is technically spec-compliant: ACCNAME
83-
// 1.2 step 2I (Tooltip) does not whitespace-trim like step 2D
84-
// (aria-label) does, so a 3-space accessible name is assigned. That is
85-
// useless in practice but not a spec violation. Default behavior flags
86-
// it as authoring hygiene; set `allowWhitespaceOnlyTitle: true` to
87-
// align with spec/peer behavior.
88-
const allowWhitespaceOnlyTitle = Boolean(context.options[0]?.allowWhitespaceOnlyTitle);
89-
9072
// Each entry: { value, node, index }
9173
// - value: trimmed title string
9274
// - node: original element node for the first occurrence
@@ -100,11 +82,7 @@ module.exports = {
10082
function processStaticTitle(node, raw) {
10183
const value = raw.trim();
10284
if (value.length === 0) {
103-
// Empty-string title always fails: no accessible name for screen readers.
104-
// Whitespace-only titles are controlled by `allowWhitespaceOnlyTitle`.
105-
if (raw.length === 0 || !allowWhitespaceOnlyTitle) {
106-
context.report({ node, messageId: 'emptyTitle' });
107-
}
85+
context.report({ node, messageId: 'emptyTitle' });
10886
return;
10987
}
11088
// Duplicate check — reports BOTH the first and the current occurrence

tests/lib/rules/template-require-iframe-title.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ ruleTester.run('template-require-iframe-title', rule, {
2121
// literals supply an accessible name the same as a text node.
2222
'<template><iframe title={{"My frame"}} /></template>',
2323
'<template><iframe title="foo" /><iframe title="bar" /></template>',
24-
// allowWhitespaceOnlyTitle: true — whitespace-only accepted.
25-
{
26-
code: '<template><iframe title=" " /></template>',
27-
options: [{ allowWhitespaceOnlyTitle: true }],
28-
},
2924
],
3025
invalid: [
3126
{
@@ -165,14 +160,6 @@ ruleTester.run('template-require-iframe-title', rule, {
165160
output: null,
166161
errors: [{ messageId: 'emptyTitle' }],
167162
},
168-
// Empty-string title is flagged even with allowWhitespaceOnlyTitle: true
169-
// (an empty string is not a whitespace string).
170-
{
171-
code: '<template><iframe title="" /></template>',
172-
output: null,
173-
options: [{ allowWhitespaceOnlyTitle: true }],
174-
errors: [{ messageId: 'emptyTitle' }],
175-
},
176163
],
177164
});
178165

@@ -191,11 +178,6 @@ hbsRuleTester.run('template-require-iframe-title', rule, {
191178
'<iframe title="" aria-hidden />',
192179
'<iframe title="" hidden />',
193180
'<iframe title="foo" /><iframe title="bar" />',
194-
// allowWhitespaceOnlyTitle: true — whitespace-only accepted in HBS too.
195-
{
196-
code: '<iframe title=" " />',
197-
options: [{ allowWhitespaceOnlyTitle: true }],
198-
},
199181
],
200182
invalid: [
201183
{

0 commit comments

Comments
 (0)