From 2625fdf6687ff1d1a51a35ad98d8a5779df9a895 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Wed, 25 Jan 2023 15:04:10 -0800 Subject: [PATCH] fix(VTT): Fix combining style selectors (#4934) When multiple style blocks exist for the same selector, they should be combined. For example, ::cue(b) { background: white; } ::cue(b) { color: blue; } should set both the background and foreground of bold tags. --- lib/text/vtt_text_parser.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/text/vtt_text_parser.js b/lib/text/vtt_text_parser.js index 83a7ca2cb3..8af41c98b6 100644 --- a/lib/text/vtt_text_parser.js +++ b/lib/text/vtt_text_parser.js @@ -234,7 +234,15 @@ shaka.text.VttTextParser = class { } } - const cue = new shaka.text.Cue(0, 0, ''); + // Continue styles over multiple selectors if necessary. + // For example, + // ::cue(b) { background: white; } ::cue(b) { color: blue; } + // should set both the background and foreground of bold tags. + let cue = styles.get(styleSelector); + if (!cue) { + cue = new shaka.text.Cue(0, 0, ''); + } + let validStyle = false; for (let i = 0; i < propertyLines.length; i++) { // We look for CSS properties. As a general rule they are separated by