Skip to content

Commit

Permalink
fix(text): Fix bug where cue comparison throws
Browse files Browse the repository at this point in the history
The cue comparison method references "this.equal",
which worked on the initial invocation of the method
but would fail on recursive calls, as "this" was
dereferenced along the way.
This was causing the cue comparison method to fail
between cues that had nested cues.
This changes the reference to be a static reference.

Change-Id: I1b8829987e3608db449213d7aafc84604fc7edac
  • Loading branch information
theodab authored and Mathias DIDIER committed Sep 16, 2020
1 parent 32d8046 commit c18852f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/text/cue.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,11 @@ shaka.text.Cue = class {
static equal(cue1, cue2) {
for (const k in cue1) {
if (k == 'nestedCues') {
// This uses shaka.text.Cue.equal rather than just this.equal, since
// otherwise recursing here will unbox the method and cause "this" to be
// undefined in deeper recursion.
if (!shaka.util.ArrayUtils.equal(
cue1.nestedCues, cue2.nestedCues, this.equal)) {
cue1.nestedCues, cue2.nestedCues, shaka.text.Cue.equal)) {
return false;
}
} else if (k == 'region' || k == 'cellResolution') {
Expand Down

0 comments on commit c18852f

Please sign in to comment.