Skip to content

Commit 15ae674

Browse files
authored
Merge pull request #416 from evocateur/fix-muted-media-has-caption
fix(media-has-caption): Use correct `muted` attribute in check
2 parents f7877d6 + 184c740 commit 15ae674

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

__tests__/src/rules/media-has-caption-test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ ruleTester.run('media-has-caption', rule, {
4646
code: '<video><track kind="Captions" /><track kind="subtitles" /></video>',
4747
},
4848
{
49-
code: '<audio mute={true}></audio>',
49+
code: '<audio muted={true}></audio>',
5050
},
5151
{
52-
code: '<video mute={true}></video>',
52+
code: '<video muted={true}></video>',
5353
},
5454
{
55-
code: '<video mute></video>',
55+
code: '<video muted></video>',
5656
},
5757
{
5858
code: '<Audio><track kind="captions" /></Audio>',
@@ -79,19 +79,19 @@ ruleTester.run('media-has-caption', rule, {
7979
options: customSchema,
8080
},
8181
{
82-
code: '<Video mute></Video>',
82+
code: '<Video muted></Video>',
8383
options: customSchema,
8484
},
8585
{
86-
code: '<Video mute={true}></Video>',
86+
code: '<Video muted={true}></Video>',
8787
options: customSchema,
8888
},
8989
{
90-
code: '<Audio mute></Audio>',
90+
code: '<Audio muted></Audio>',
9191
options: customSchema,
9292
},
9393
{
94-
code: '<Audio mute={true}></Audio>',
94+
code: '<Audio muted={true}></Audio>',
9595
options: customSchema,
9696
},
9797
].map(parserOptionsMapper),
@@ -108,12 +108,12 @@ ruleTester.run('media-has-caption', rule, {
108108
errors: [expectedError],
109109
},
110110
{
111-
code: '<Audio mute={false}></Audio>',
111+
code: '<Audio muted={false}></Audio>',
112112
options: customSchema,
113113
errors: [expectedError],
114114
},
115115
{
116-
code: '<Video mute={false}></Video>',
116+
code: '<Video muted={false}></Video>',
117117
options: customSchema,
118118
errors: [expectedError],
119119
},

docs/rules/media-has-caption.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Providing captions for media is essential for deaf users to follow along. Captions should be a transcription or translation of the dialogue, sound effects, relevant musical cues, and other relevant audio information. Not only is this important for accessibility, but can also be useful for all users in the case that the media is unavailable (similar to `alt` text on an image when an image is unable to load).
44

5-
The captions should contain all important and relevant information to understand the corresponding media. This may mean that the captions are not a 1:1 mapping of the dialogue in the media content. However, captions are *not* necessary for video components with the mute attribute.
5+
The captions should contain all important and relevant information to understand the corresponding media. This may mean that the captions are not a 1:1 mapping of the dialogue in the media content. However, captions are *not* necessary for video components with the `muted` attribute.
66

77
### References
88

@@ -31,7 +31,7 @@ For the `audio`, `video`, and `track` options, these strings determine which JSX
3131
```jsx
3232
<audio><track kind="captions" {...props} /></audio>
3333
<video><track kind="captions" {...props} /></video>
34-
<video mute {...props} ></video>
34+
<video muted {...props} ></video>
3535
```
3636

3737
### Fail

src/rules/media-has-caption.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ module.exports = {
5050
if (!isMediaType(context, type)) {
5151
return;
5252
}
53-
const muteProp = getProp(element.attributes, 'mute');
54-
const mutePropVal: boolean = getLiteralPropValue(muteProp);
55-
if (mutePropVal === true) {
53+
const mutedProp = getProp(element.attributes, 'muted');
54+
const mutedPropVal: boolean = getLiteralPropValue(mutedProp);
55+
if (mutedPropVal === true) {
5656
return;
5757
}
5858
// $FlowFixMe https://github.com/facebook/flow/issues/1414

0 commit comments

Comments
 (0)