Skip to content

Commit

Permalink
Treat kind attribute as enumerated (#269)
Browse files Browse the repository at this point in the history
* Treat kind attribute as enumerated
  • Loading branch information
Jym77 authored Jun 17, 2020
1 parent 3ff77d1 commit b5ea663
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions packages/alfa-rules/src/common/applicability/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -39,7 +38,23 @@ export function video(
Element.isElement,
and(
hasName("track"),
hasAttribute("kind", equals(track.kind))
(trackElement) =>
trackElement
.attribute("kind")
// @see https://html.spec.whatwg.org/multipage/media.html#attr-track-kind
.map(
(kind) =>
kind
.enumerate(
"subtitles",
"captions",
"descriptions",
"chapters",
"metadata"
)
.getOr("metadata") // invalid value default
)
.getOr("subtitles") === track.kind // missing value default
)
)
)
Expand Down

0 comments on commit b5ea663

Please sign in to comment.