diff --git a/runtime/js/jslib.js b/runtime/js/jslib.js index da4db1a2bb..03fbdbefe9 100644 --- a/runtime/js/jslib.js +++ b/runtime/js/jslib.js @@ -416,7 +416,8 @@ function caml_js_wrap_callback_unsafe(f) { //Requires: caml_callback, caml_js_wrap_callback function caml_js_wrap_meth_callback(f) { return function (...args) { - var res = caml_callback(f, [this, ...args]); + args.unshift(this); + var res = caml_callback(f, args); return res instanceof Function ? caml_js_wrap_callback(res) : res; }; } @@ -431,8 +432,8 @@ function caml_js_wrap_meth_callback_arguments(f) { //Requires: caml_callback function caml_js_wrap_meth_callback_strict(arity, f) { return function (...args) { - args = [this, ...args]; - args.length = arity + 1; + args.length = arity; + args.unshift(this); return caml_callback(f, args); }; } @@ -441,7 +442,7 @@ function caml_js_wrap_meth_callback_strict(arity, f) { function caml_js_wrap_meth_callback_unsafe(f) { return function (...args) { var len = caml_js_function_arity(f); - args = [this, ...args]; + args.unshift(this); args.length = len; return caml_callback(f, args); }; diff --git a/runtime/js/stdlib.js b/runtime/js/stdlib.js index cd33308551..307986787d 100644 --- a/runtime/js/stdlib.js +++ b/runtime/js/stdlib.js @@ -53,7 +53,7 @@ function caml_call_gen(f, args) { default: { var g = function (...extra_args) { if (extra_args.length === 0) extra_args = [undefined]; - return caml_call_gen(f, [...args, ...extra_args]); + return caml_call_gen(f, args.concat(extra_args)); }; } } @@ -111,7 +111,7 @@ function caml_call_gen(f, args) { args.length = argsLen; var g = function (...extra_args) { if (extra_args.length === 0) extra_args = [undefined]; - return caml_call_gen(f, [...args, ...extra_args]); + return caml_call_gen(f, args.concat(extra_args)); }; } } diff --git a/runtime/js/stdlib_modern.js b/runtime/js/stdlib_modern.js index 82ca3c7fee..88c4806a1f 100644 --- a/runtime/js/stdlib_modern.js +++ b/runtime/js/stdlib_modern.js @@ -51,7 +51,7 @@ function caml_call_gen(f, args) { default: { var g = function (...extra_args) { if (extra_args.length === 0) extra_args = [undefined]; - return caml_call_gen(f, [...args, ...extra_args]); + return caml_call_gen(f, args.concat(extra_args)); }; } } @@ -107,7 +107,7 @@ function caml_call_gen(f, args) { args.length = argsLen; var g = function (...extra_args) { if (extra_args.length === 0) extra_args = [undefined]; - return caml_call_gen(f, [...args, ...extra_args]); + return caml_call_gen(f, args.concat(extra_args)); }; } }