From b0ce56fff066d5b043946af876b711290cb8b17a Mon Sep 17 00:00:00 2001 From: Jean-Yves Moyen Date: Wed, 17 Jun 2020 11:12:25 +0200 Subject: [PATCH 1/3] Treat kind attribute as enumerated --- .../src/common/applicability/video.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/alfa-rules/src/common/applicability/video.ts b/packages/alfa-rules/src/common/applicability/video.ts index 120d5fad8d..520d54f6fd 100644 --- a/packages/alfa-rules/src/common/applicability/video.ts +++ b/packages/alfa-rules/src/common/applicability/video.ts @@ -39,7 +39,22 @@ export function video( Element.isElement, and( hasName("track"), - hasAttribute("kind", equals(track.kind)) + (trackElement) => + trackElement + .attribute("kind") + .map( + (kind) => + kind + .enumerate( + "subtitles", + "captions", + "descriptions", + "chapters", + "metadata" + ) + .getOr("metadata") // invalid value default + ) + .getOr("subtitles") === track.kind // missing value default ) ) ) From bafc7367d82bc05fc419014d3c5a0fe3c33b2a8e Mon Sep 17 00:00:00 2001 From: Jean-Yves Moyen Date: Wed, 17 Jun 2020 11:15:19 +0200 Subject: [PATCH 2/3] Add link to specs in comment --- packages/alfa-rules/src/common/applicability/video.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/alfa-rules/src/common/applicability/video.ts b/packages/alfa-rules/src/common/applicability/video.ts index 520d54f6fd..da72186c4e 100644 --- a/packages/alfa-rules/src/common/applicability/video.ts +++ b/packages/alfa-rules/src/common/applicability/video.ts @@ -42,6 +42,7 @@ export function video( (trackElement) => trackElement .attribute("kind") + // @see https://html.spec.whatwg.org/multipage/media.html#attr-track-kind .map( (kind) => kind From 1e24cd0f33491230ebe830611596fa53cd1f8e88 Mon Sep 17 00:00:00 2001 From: Jean-Yves Moyen Date: Wed, 17 Jun 2020 11:27:40 +0200 Subject: [PATCH 3/3] Clean up --- packages/alfa-rules/src/common/applicability/video.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/alfa-rules/src/common/applicability/video.ts b/packages/alfa-rules/src/common/applicability/video.ts index da72186c4e..f606d71cdc 100644 --- a/packages/alfa-rules/src/common/applicability/video.ts +++ b/packages/alfa-rules/src/common/applicability/video.ts @@ -8,11 +8,10 @@ import { Predicate } from "@siteimprove/alfa-predicate"; import { isVisible } from "../predicate/is-visible"; import { Question } from "../question"; -import { hasAttribute } from "../predicate/has-attribute"; const { isElement, hasName, hasNamespace } = Element; const { filter, map, some } = Iterable; -const { and, equals } = Predicate; +const { and } = Predicate; export function video( document: Document,