Skip to content

Commit 49a267e

Browse files
committed
fix: don't issue a11y warning for video without captions if it has no
1 parent 0cdc431 commit 49a267e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.changeset/dark-buckets-hang.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: don't issue a11y warning for `<video>` without captions if it has no `src`

packages/svelte/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,17 @@ export function check_element(node, context) {
486486
case 'video': {
487487
const aria_hidden_attribute = attribute_map.get('aria-hidden');
488488
const aria_hidden_exist = aria_hidden_attribute && get_static_value(aria_hidden_attribute);
489+
489490
if (attribute_map.has('muted') || aria_hidden_exist === 'true' || has_spread) {
490491
return;
491492
}
493+
494+
if (!attribute_map.has('src')) {
495+
// don't warn about missing captions if `<video>` has no `src` —
496+
// could e.g. be playing a MediaStream
497+
return;
498+
}
499+
492500
let has_caption = false;
493501
const track = /** @type {AST.RegularElement | undefined} */ (
494502
node.fragment.nodes.find((i) => i.type === 'RegularElement' && i.name === 'track')

0 commit comments

Comments
 (0)