Skip to content

Commit ac71dd6

Browse files
committed
[Fix] fix Safari 12.0 bug
1 parent c32142d commit ac71dd6

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

polyfill.js

+6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ module.exports = function getPolyfill() {
66
if (!Array.prototype.reverse) {
77
return implementation;
88
}
9+
var a = [1, 2]; // safari 12.0
10+
if (String(a) === String(a.reverse())) {
11+
return implementation;
12+
}
13+
914
try {
15+
// node < 4
1016
Array.prototype.reverse.call('abc');
1117
return implementation;
1218
} catch (e) {

test/tests.js

+3
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ module.exports = function (reverse, t) {
3838
t.deepEqual(sparse4, [4, , , 1], 'original sparse array is reversed');
3939
t.deepEqual(sparse4R, [4, , , 1], 'returned sparse array is reversed');
4040
t.equal(sparse4, sparse4R, 'returned sparse array is the original sparse array');
41+
42+
var arr = [1, 2];
43+
t.notEqual(String(arr), String(reverse(arr), 'does not have safari 12.0 bug'));
4144
};

0 commit comments

Comments
 (0)