Skip to content

Commit

Permalink
fix(VTT): Fix combining style selectors (#4934)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joeyparrish committed Jan 30, 2023
1 parent 8624759 commit 2625fdf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/text/vtt_text_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2625fdf

Please sign in to comment.