Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari 12 workaround for array.reverse caching #376

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions dist/vtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -1518,21 +1518,28 @@
cue = styleBox.cue,
linePos = computeLinePos(cue),
axis = [];
// Safari 12 introduced a bug where the reverse order of an array instantiated with primitives
// is cached after array.prototype.reverse is called (https://bugs.webkit.org/show_bug.cgi?id=188794).
// Variables are used as a workaround.
const posY = '+y';
const negY = '-y';
const posX = '+x';
const negX = '-x';

// If we have a line number to align the cue to.
if (cue.snapToLines) {
var size;
switch (cue.vertical) {
case "":
axis = [ "+y", "-y" ];
axis = [posY, negY];
size = "height";
break;
case "rl":
axis = [ "+x", "-x" ];
axis = [posX, negX];
size = "width";
break;
case "lr":
axis = [ "-x", "+x" ];
axis = [negX, posX];
size = "width";
break;
}
Expand Down Expand Up @@ -1595,7 +1602,7 @@
break;
}

axis = [ "+y", "-x", "+x", "-y" ];
axis = [posY, negX, posX, negY];

// Get the box position again after we've applied the specified positioning
// to it.
Expand Down