-
Notifications
You must be signed in to change notification settings - Fork 662
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
The auto-generated outgoingPort JavaScript neglects to escape a record field named "default" #1510
Labels
Comments
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
I couldn't attach the .elm file, so here it is:
|
Tracking in #1685 now. Thank you for the report! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Elm version 0.17.1
macOS Sierra version 10.12
Opera 40.0.2308.81
If I build an application that uses an outgoing port to save its state, after the pattern of the elm-todomvc application, and its model contains a record with a field named "default", then the resulting JavaScript code will error as soon as it attempts to reload saved state.
I built a full working Elm project for this and pushed it to https://github.com/billstclair/elm-default-in-port-record. Same Elm code, but an index.html that lets you run it easily.
If you save the file in the next comment as
default-in-port-record.elm
, and compile it with:You can find the following code in the resulting
index.js
.default
is properly escaped with a prefixed "$" in the compilation of theupdate
function:But it is NOT escaped in the code that converts the Elm data structures into a structure suitable for JSON encoding for
localStorage.setItem()
:I looked for where this is done, but am not familiar enough with the compiler to find it.
The text was updated successfully, but these errors were encountered: