Skip to content

Commit 3b3e17a

Browse files
committed
fix(template-require-media-caption): match kind="captions" case-insensitively
HTML enumerated attribute values are case-insensitive per the spec: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attributes Before: <track kind="Captions"> and kind="CAPTIONS" were treated as missing a captions track. Lowercase the value before comparison. Matches jsx-a11y and vue-a11y (both lowercase before comparing).
1 parent 24882a3 commit 3b3e17a

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module.exports = {
7474
}
7575

7676
if (kindAttr.value?.type === 'GlimmerTextNode') {
77-
return kindAttr.value.chars === 'captions';
77+
return kindAttr.value.chars.toLowerCase() === 'captions';
7878
}
7979

8080
return false;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ ruleTester.run('template-require-media-caption', rule, {
3131
</template>`,
3232

3333
'<template><video><track kind="captions" /></video></template>',
34+
// HTML enumerated attribute values are case-insensitive, so "Captions" is
35+
// the same as "captions" for the track element. Matches jsx-a11y/vue-a11y.
36+
'<template><video><track kind="Captions" /></video></template>',
37+
'<template><video><track kind="CAPTIONS" /></video></template>',
3438
'<template><audio muted="true"></audio></template>',
3539
'<template><video muted></video></template>',
3640
'<template><audio muted={{this.muted}}></audio></template>',

0 commit comments

Comments
 (0)