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

Clarify enum and object literals usage in scalajs-dom #842

Open
zetashift opened this issue Mar 19, 2024 · 0 comments
Open

Clarify enum and object literals usage in scalajs-dom #842

zetashift opened this issue Mar 19, 2024 · 0 comments

Comments

@zetashift
Copy link
Contributor

zetashift commented Mar 19, 2024

Enums

Enums currently are defined separately for Scala 2 and Scala 3,not only that these enums, are anonymous objects backed by string fields. Because scalajs-dom wants to stay as close as possible to the JavaScript Web API.

we use enums like this:

PredefinedColorSpace.`display-p3` 

Object literals

These are anonymous objects in Scala 3:

ImageData(200, 100, new { colorSpace = PredefinedColorSpace.`display-p3` })
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the object literal

They are not something like ImageSettings.apply(...) because of sjs-dom goal, stay as close as possible to the JS API.

Not clean, but we should documentate why it is like this, with some example, most likely adding this to CONTRIBUTING.md.

@zetashift zetashift changed the title Clarify enum usage in scalajs-dom Clarify enum and object literals usage in scalajs-dom Mar 19, 2024
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

1 participant