From 8a4aeb82ab4fc175dff72d5dfafadd6ac5f9803f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Hedin=20Br=C3=B8nner?= Date: Thu, 5 Oct 2017 14:12:43 +0200 Subject: [PATCH] Arrow functions doesn't have arguments in newer spidermonkey Gnome-shell 3.26 uses a newer spidermonkey engine which doesn't give arrow functions access to the `arguments` keyword. Using `function` instead fixes this. Also use [...arguments] to copy arguments as slice apparently can have a performance penalty: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments --- utils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils.js b/utils.js index 6c9799d..0007d93 100644 --- a/utils.js +++ b/utils.js @@ -1,7 +1,7 @@ debug_all = true; // Consider the default value in `debug_filter` to be true debug_filter = { "#preview": false }; -debug = () => { +debug = function() { let keyword = arguments[0]; let filter = debug_filter[keyword]; if (filter === false) @@ -10,7 +10,7 @@ debug = () => { print(Array.prototype.join.call(arguments, " | ")); } -print_stacktrace = (error) => { +print_stacktrace = function(error) { let trace; if (!error) { trace = (new Error()).stack.split("\n") @@ -23,7 +23,7 @@ print_stacktrace = (error) => { let filtered = trace.filter((frame) => { return frame !== "wrapper@resource:///org/gnome/gjs/modules/lang.js:178" }); - let args = Array.prototype.splice.call(arguments); + let args = [...arguments]; args.splice(0, 1, "stacktrace:"+(args[0] ? args[0] : "")) // Use non-breaking space to encode new lines (otherwise every frame is // prefixed by timestamp) @@ -41,7 +41,7 @@ framestr = (rect) => { * redefine the function without re-registering all signal handler, keybindings, * etc. (this is like a function symbol in lisp) */ -dynamic_function_ref = (handler_name, owner_obj) => { +dynamic_function_ref = function(handler_name, owner_obj) { owner_obj = owner_obj || window; return function() { owner_obj[handler_name].apply(this, arguments);