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

Map JSX props to DOM attributes/props in a systematic way #44

Open
jussisaurio opened this issue Nov 9, 2020 · 0 comments
Open

Map JSX props to DOM attributes/props in a systematic way #44

jussisaurio opened this issue Nov 9, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@jussisaurio
Copy link
Collaborator

jussisaurio commented Nov 9, 2020

Currently in setProp we make some decisions when to use setAttribute and when to use direct property assignment, etc. For example, if user provides draggable=true (boolean) we set it with direct assignment because setAttribute wouldn't work as 'draggable' is not a boolean (https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable). Direct assignment apparently leads to 'true' being coerced into a string and thus it works.

Anyway: there's some if-else technology used to decide what to do in which particular case, and it will eventually get out of hand as these special cases get larger in number. We would probably benefit from having a systematic way to handle them.

For reference, here is what React does for different kinds of props (tldr: mostly setAttribute with a few exceptions, and special handling for various props like coercion to string):

https://github.com/facebook/react/blob/b61174fb7b09580c1ec2a8f55e73204b706d2935/packages/react-dom/src/shared/DOMProperty.js

@jussisaurio jussisaurio added the enhancement New feature or request label Nov 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant