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

Spread operator doesn't evaluate internals #73

Open
ElliotChong opened this issue Apr 22, 2016 · 1 comment
Open

Spread operator doesn't evaluate internals #73

ElliotChong opened this issue Apr 22, 2016 · 1 comment

Comments

@ElliotChong
Copy link

ElliotChong commented Apr 22, 2016

As per CoffeeScript's default behavior of evaluating statements, I was surprised to find that the following statements within a spread operator result in the CJSX error: SyntaxError: Unexpected end of input: unclosed CJSX_EL

render: ->
  <SomeComponent {...{foo: "bar"}}/>
render: ->
  foo = "bar"
  <SomeComponent {...{foo}}/>
render: ->
  foo = "bar"
  <SomeComponent {...({foo})}/>
render: ->
  foo = "bar"
  <SomeComponent {...(do -> {foo})}/>

Expected output is for a structured assignment of { foo: foo } and passing that result to the spread method.

@ElliotChong
Copy link
Author

ElliotChong commented Apr 22, 2016

I've started work on a fix for #73, #62, and #39 @ https://github.com/ElliotChong/coffee-react-transform/commits/patch-1

It passes all existing tests and it should fix #62 and #39; however, I'm having some trouble with the assignment requirement outlined in this issue (#73).

It seems like the closing curly brace in structured assignment / Object creation isn't being output... I'm wondering if there's some code that might be de-duplicating curly braces that are back to back?

Test Case:

##desc
self closing tag with spread attribute with object creation
##input
<Component a={b} {... { d: "e" } } b="c" />
##expected
React.createElement(Component, React.__spread({"a": (b)},  {"d": "e"} , {"b": "c"}))
##end

Output:

Error: compile error in testcase: self closing tag with spread attribute with object creation

React.createElement(Component, React.__spread({"a": (b)},  { d: "e" , {"b": "c"}))

Test Case:

##desc
self closing spread attribute on next line with object creation
##input
<Component
  a="b"
  c="d"
  {...{ e: "f"}}

/>
##expected
React.createElement(Component, React.__spread({ \
  "a": "b",  \
  "c": "d"
  }, { e: "f"}

))
##end

Output:

Error: compile error in testcase: self closing spread attribute on next line with object creation

React.createElement(Component, React.__spread({ \
  "a": "b",  \
  "c": "d"
  }, ({ e: "f"



))

@jsdf Any thoughts on why that closing curly brace isn't appearing?

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

No branches or pull requests

1 participant