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

style tags compile even without a value in some cases #484

Open
evbo opened this issue Jun 16, 2021 · 1 comment
Open

style tags compile even without a value in some cases #484

evbo opened this issue Jun 16, 2021 · 1 comment

Comments

@evbo
Copy link

evbo commented Jun 16, 2021

This compiles and probably shouldn't in case someone accidentally adds a style tag and forgets a value for it, causing runtime failure:

div()(
  div(style := /*what if this is a dangerous typo? compiler should catch it!*/
    h3(style := js.Dynamic.literal("marginBottom" -> 20))("no idea!"),
    "why this compile?!"
  )
)

Originally reported on gitter: https://gitter.im/shadaj/slinky?at=60c608fad855766185d5a4a2

@shadaj
Copy link
Owner

shadaj commented Jul 26, 2021

Ah, style is defined to take a js.Object (so that js.Dynamic.literal can be used), but ReactElement is also a js.Object, so it can be used there instead. The ideal solution would be to change style to take a js.Dictionary, but unfortunately then we lose the literal syntax.

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

No branches or pull requests

2 participants