From: Joe Wreschnig Date: Tue, 23 Sep 2014 12:15:03 +0000 (+0200) Subject: Work around a Safari JIT bug. X-Git-Url: https://git.yukkurigames.com/?a=commitdiff_plain;h=870ba16684b6eab5b8b14a3523e8b6f2e075c675;p=yuu.git Work around a Safari JIT bug. --- diff --git a/src/yuu/yf.js b/src/yuu/yf.js index 5df966d..3ea8b20 100644 --- a/src/yuu/yf.js +++ b/src/yuu/yf.js @@ -197,8 +197,17 @@ case 1: return function () { return f.call(this, arguments); }; default: return function () { - arguments[length - 1] = slice(arguments, length - 1); - return f.apply(this, arguments); + /* The following code can do this without creating a + new array, but it causes function calls to randomly + not happen in Safari (Mobile and OS X) - presumably + due to some JIT bug, because surrounding it in + an empty try/catch block also makes it work. + + arguments[length - 1] = slice(arguments, length - 1); + */ + var args = slice(arguments, 0, length - 1); + args.push(slice(arguments, length - 1)); + return f.apply(this, args); }; } }