From f31981197caf05a6f644115040dd1aa123ddfbff Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Tue, 23 Oct 2018 09:30:17 -0400 Subject: [PATCH] Call reverse on copy of axis array Safari 12 bug workaround --- lib/vtt.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/vtt.js b/lib/vtt.js index 66ab23f..d664c99 100644 --- a/lib/vtt.js +++ b/lib/vtt.js @@ -925,7 +925,11 @@ // video, depending on the writing direction, and reverse our axis directions. if (linePos < 0) { position += cue.vertical === "" ? containerBox.height : containerBox.width; - axis = axis.reverse(); + + // Safari 12 introduced a bug where the reverse order of an array is cached after calling + // array.prototype.reverse (https://bugs.webkit.org/show_bug.cgi?id=188794). + // As a workaround, call reverse on a copy of the 'axis' array, instead of calling it directly on the original var + axis = axis.slice().reverse(); } // Move the box to the specified position. This may not be its best