Closed c-harding closed 5 years ago
👍 looks good to me
@scottkellum please wait with merging. I see a potential issue.
@scottkellum please wait with merging. I see a potential issue.
@KargJonas what potential issue do you see? Was it fixed in 25f3d86?
I have two main concerns with your changes. 1) Implementing a json parser by hand with regex is a very bad idea. Maybe look at some prebuilt tools. 2) Code readability. safeEval was implemented with #14 in mind.
Make small changes in your PRs and I'll merge them one by one.
Yeah - 50kb seems like a lot of overhead.. We'll find a better solution :) It's clear that we need a separate function for evaluating code, the nice API of safeEval() was just too tempting not to implement :sweat_smile: . Maybe something like this:
const fn = constructFunction(js, ['arg1', 'arg2', 'arg3']); fn.run({arg1: 42, arg2: 3.1415, arg3: 0}, element);
I added bundling in #29 which should we merge first?
As discussed in #7,
eval
is probably not needed in--data
, and so I have converted this to JSON (backwards-compatible to also support JavaScript syntax of single-quoted strings, non-quoted keys and trailing commas). Elsewhere, I have replaced calls tosafe_eval
with theFunction
constructor, which means each function is only generated once, rather than once per matching element.I have also changed the way that enclosing parentheses are parsed: instead of blindly discarding the first and last characters, this now only happens if they are actually a pair of parentheses (
cjss.js:13
).