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

JSX props map to object properties #47

Merged
merged 1 commit into from
Sep 26, 2019
Merged

Conversation

mindplay-dk
Copy link
Contributor

JSX props map to object properties by default and falls back to attributes - except for SVG elements, which always use attributes.

Closes #46

I will add some inline notes to the PR in a moment.

src/dom.js Show resolved Hide resolved
@mindplay-dk
Copy link
Contributor Author

mindplay-dk commented Sep 26, 2019

Since I don't know how to get the tests working yet, there are no tests for this yet.

You can see working examples here, including both class and className working now, readOnly property working with a literal true, and SVG element with attributes rather than properties updating correctly, text nodes updating with nodeValue, and <input> elements updating with value.

@yisar
Copy link
Collaborator

yisar commented Sep 26, 2019

Hey, I'm back.
I see that use cases work great, so merge this request first~

Thank you very much.

@yisar yisar merged commit 4545e3a into frejs:master Sep 26, 2019
@yisar
Copy link
Collaborator

yisar commented Sep 26, 2019

I don't quite understand why it can support className. How does it work??

@mindplay-dk
Copy link
Contributor Author

I don't quite understand why it can support className. How does it work??

The test for name in dom will detect it and set it - for example:

console.log("className" in (document.createElement("div"))); // => true

This will cause the property to be set.

As opposed to:

console.log("class" in (document.createElement("div"))); // => false

This will continue on to setAttribute() as before.

@mindplay-dk mindplay-dk deleted the object-props branch October 5, 2019 13:04
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

Successfully merging this pull request may close these issues.

Property-names get lower-cased?
2 participants