From 61cf366f6154333665ae28c9ef2941cd0d492216 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 4 Feb 2019 13:31:25 -0600 Subject: [PATCH] Try evaling tasks with and without parentheses, closes #326 --- inst/www/htmlwidgets.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/inst/www/htmlwidgets.js b/inst/www/htmlwidgets.js index ed9837d9..3ba87ddc 100644 --- a/inst/www/htmlwidgets.js +++ b/inst/www/htmlwidgets.js @@ -233,7 +233,17 @@ theseArgs = theseArgs.concat([task.data]); task = task.code; } - var taskFunc = eval("(" + task + ")"); + try { + var taskFunc = eval("(" + task + ")"); + } catch(err) { + try { + var taskFunc = eval(task); + } catch(error) { + console.error(err); + console.error(error); + } + } + if (typeof(taskFunc) !== "function") { throw new Error("Task must be a function! Source:\n" + task); }