EricSmekens / jsep

JavaScript Expression Parser
http://ericsmekens.github.io/jsep/
MIT License
836 stars 136 forks source link

Nested ternary operator does not work when object plugin is used #183

Closed untersalmberger closed 3 years ago

untersalmberger commented 3 years ago

When the object plugin is registered, a nested ternary operator no longer works. jsep throws an exception that it expects a : at some position.

That's what works without the object plugin, but not with the object plugin:

import jsep from "jsep";
import object from "@jsep-plugin/object";
jsep.plugins.register(object);

let works = jsep("a ? 0 : 1"); // works also with `object` plugin
let worksAsWell = jsep("a ? 0 : (b ? 1 : 2)"); // works also with `object` plugin
let doesNotWork = jsep("a ? 0 : b ? 1 : 2"); // throws exception as soon as the `object` plugin is registered

Other plugins like the comment plugin do not harm.

Looks like an "unresolved technical issue" :)

6utt3rfly commented 3 years ago

Thanks for reporting @untersalmberger . I can see the issue and will try to fix it sometime this weekend :)

untersalmberger commented 3 years ago

You guys are amazing! I love your work!

grimalschi commented 3 years ago

Thank you for fixing this!

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version @jsep-plugin/object-v1.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version @jsep-plugin/ternary-v1.0.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

6utt3rfly commented 3 years ago

(also jsep@v1.1.0, since that includes the ternary plugin by default)