Skip to content

Commit fd9c410

Browse files
committed
Fix template-require-media-caption: skip caption check when muted is dynamic
Port had no GlimmerConcatStatement handling for the muted attribute, so <video muted="{{isMuted}}"> false-positively required captions. Treat ConcatStatement (and other non-text values) as muted/exempt to match upstream.
1 parent 56f913d commit fd9c410

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

lib/rules/template-require-media-caption.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ module.exports = {
5353
return;
5454
}
5555
}
56+
57+
// Any other dynamic value (e.g. muted="{{isMuted}}" → ConcatStatement,
58+
// or muted={{#if ...}}...{{/if}} → BlockStatement) → treat as exempt.
59+
// Matches upstream ember-template-lint behavior where MustacheStatement,
60+
// BlockStatement, or any non-text/non-"false" value is considered muted.
61+
if (
62+
value.type !== 'GlimmerTextNode' &&
63+
value.type !== 'GlimmerMustacheStatement'
64+
) {
65+
return;
66+
}
5667
}
5768

5869
// Check if there's a track element with kind="captions" as a child

tests/lib/rules/template-require-media-caption.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ ruleTester.run('template-require-media-caption', rule, {
3434
'<template><audio muted="true"></audio></template>',
3535
'<template><video muted></video></template>',
3636
'<template><audio muted={{this.muted}}></audio></template>',
37+
'<template><video muted="{{isMuted}}"><source src="movie.mp4" /></video></template>',
38+
'<template><audio muted="{{this.isMuted}}"></audio></template>',
3739
'<template><video><track kind="captions" /><track kind="descriptions" /></video></template>',
3840
],
3941

@@ -148,6 +150,8 @@ hbsRuleTester.run('template-require-media-caption', rule, {
148150
'<audio muted="true"></audio>',
149151
'<video muted></video>',
150152
'<audio muted={{this.muted}}></audio>',
153+
'<video muted="{{isMuted}}"><source src="movie.mp4" /></video>',
154+
'<audio muted="{{this.isMuted}}"></audio>',
151155
'<video><track kind="captions" /><track kind="descriptions" /></video>',
152156
],
153157
invalid: [

0 commit comments

Comments
 (0)