add a11y-media-has-caption check (#5075)

pull/5249/head
Bassam Ismail 4 years ago committed by GitHub
parent 308f3c284d
commit fb51dd8f07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -528,6 +528,25 @@ export default class Element extends Node {
}
}
if (this.is_media_node()) {
if (attribute_map.has('muted')) {
return;
}
let has_caption;
const track = this.children.find((i: Element) => i.name === 'track');
if (track) {
has_caption = track.attributes.find(a => a.name === 'kind' && a.get_static_value() === 'captions');
}
if (!has_caption) {
component.warn(this, {
code: `a11y-media-has-caption`,
message: `A11y: Media elements must have a <track kind="captions">`
});
}
}
if (a11y_no_onchange.has(this.name)) {
if (handlers_map.has('change') && !handlers_map.has('blur')) {
component.warn(this, {

@ -1,2 +1,2 @@
<div><video class="svelte-xyz" autoplay></video>
<video></video></div>
<div><video class="svelte-xyz" autoplay muted></video>
<video muted></video></div>

@ -1,10 +1,10 @@
<div>
<video autoplay></video>
<video></video>
<video autoplay muted></video>
<video muted></video>
</div>
<style>
[autoplay] {
color: red;
}
</style>
</style>

@ -0,0 +1,4 @@
<video><track kind="captions"/></video>
<video></video>
<video><track /></video>
<audio muted></audio>

@ -0,0 +1,32 @@
[
{
"code": "a11y-media-has-caption",
"end": {
"character": 55,
"column": 15,
"line": 2
},
"message": "A11y: Media elements must have a <track kind=\"captions\">",
"pos": 40,
"start": {
"character": 40,
"column": 0,
"line": 2
}
},
{
"code": "a11y-media-has-caption",
"end": {
"character": 80,
"column": 24,
"line": 3
},
"message": "A11y: Media elements must have a <track kind=\"captions\">",
"pos": 56,
"start": {
"character": 56,
"column": 0,
"line": 3
}
}
]
Loading…
Cancel
Save