Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
untersalmberger opened this issue Sep 23, 2021 · 6 comments · Fixed by #184
Closed

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

untersalmberger opened this issue Sep 23, 2021 · 6 comments · Fixed by #184
Labels

Comments

@untersalmberger
Copy link

untersalmberger commented Sep 23, 2021

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
Copy link
Collaborator

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

@untersalmberger
Copy link
Author

You guys are amazing! I love your work!

6utt3rfly added a commit that referenced this issue Sep 25, 2021
The object plugin adds a `:` binary operator which interferes with ternaries. The previous version would work with both objects and ternaries, but not when nested without parentheses. Fixes cases like, `a ? 0 : b ? 1 : 2` and similar.

Fixes #183
@grimalschi
Copy link

Thank you for fixing this!

github-actions bot pushed a commit that referenced this issue Oct 3, 2021
# @jsep-plugin/ternary-v1.0.0 (2021-10-03)

### Bug Fixes

* support nested ternaries with the object plugin loaded ([cf37c29](cf37c29)), closes [#183](#183)
@github-actions
Copy link

github-actions bot commented Oct 3, 2021

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

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this issue Oct 3, 2021
# [@jsep-plugin/ternary-v1.0.1](https://github.com/EricSmekens/jsep/compare/@jsep-plugin/ternary-v1.0.0...@jsep-plugin/ternary-v1.0.1) (2021-10-03)

### Bug Fixes

* support nested ternaries with the object plugin loaded ([cf37c29](cf37c29)), closes [#183](#183)
@github-actions
Copy link

github-actions bot commented Oct 3, 2021

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

The release is available on:

Your semantic-release bot 📦🚀

@6utt3rfly
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants