Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dark-buckets-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: don't issue a11y warning for `<video>` without captions if it has no `src`
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,17 @@ export function check_element(node, context) {
case 'video': {
const aria_hidden_attribute = attribute_map.get('aria-hidden');
const aria_hidden_exist = aria_hidden_attribute && get_static_value(aria_hidden_attribute);

if (attribute_map.has('muted') || aria_hidden_exist === 'true' || has_spread) {
return;
}

if (!attribute_map.has('src')) {
// don't warn about missing captions if `<video>` has no `src` —
// could e.g. be playing a MediaStream
return;
}

let has_caption = false;
const track = /** @type {AST.RegularElement | undefined} */ (
node.fragment.nodes.find((i) => i.type === 'RegularElement' && i.name === 'track')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<video><track kind="captions"/></video>
<video></video>
<video><track /></video>
<video src="x"><track kind="captions"/></video>
<video src="x"></video>
<video src="x"><track /></video>
<audio></audio>
<video aria-hidden="true"></video>
<video aria-hidden="false"></video>
<video src="x" aria-hidden="true"></video>
<video src="x" aria-hidden="false"></video>
<video></video> <!-- no src -->
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"code": "a11y_media_has_caption",
"end": {
"column": 15,
"column": 23,
"line": 2
},
"message": "`<video>` elements must have a `<track kind=\"captions\">`",
Expand All @@ -14,7 +14,7 @@
{
"code": "a11y_media_has_caption",
"end": {
"column": 24,
"column": 32,
"line": 3
},
"message": "`<video>` elements must have a `<track kind=\"captions\">`",
Expand All @@ -26,7 +26,7 @@
{
"code": "a11y_media_has_caption",
"end": {
"column": 35,
"column": 43,
"line": 6
},
"message": "`<video>` elements must have a `<track kind=\"captions\">`",
Expand Down
Loading