From d88d58e8db80b42cfd99fd41be941f720273db48 Mon Sep 17 00:00:00 2001 From: Bassam Ismail Date: Fri, 26 Jun 2020 20:55:04 +0530 Subject: [PATCH 1/3] fix(820): check if media has captions --- src/compiler/compile/nodes/Element.ts | 20 ++++++++++++ .../a11y-media-has-caption/input.svelte | 4 +++ .../a11y-media-has-caption/warnings.json | 32 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 test/validator/samples/a11y-media-has-caption/input.svelte create mode 100644 test/validator/samples/a11y-media-has-caption/warnings.json diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 7a70e603a77f..00b5e5279df5 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -507,6 +507,26 @@ 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 such as