Work around a Safari JIT bug.
[yuu.git] / src / yuu / yf.js
index 5df966d..3ea8b20 100644 (file)
         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);
             };
         }
     }