-
Notifications
You must be signed in to change notification settings - Fork 40
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
Passing single node as children does not seem to work with preact-hyperscript #43
Comments
This library aims to be a very thin layer of sugar on top of whichever hyperscript implementation you are using. Like @staltz mentioned in the snabbdom issue, it is not trivial to tell nodes and other objects apart. Even more so since I wouldn't know which hyperscript library you are using. Because of these concerns, I am very reluctant to "polyfill" this functionality. |
2 characters really cannot be so much bloat to type. React and (consequently) Preact did this "wrong" in my opinion from the beginning. It is much easier to distinguish (for both library code and some person reading code) what is props/data and what is children: the former is always an object, the latter always an array. I think React/Preact do this as some kind of optimization since their primary usage is through JSX. People using hyperscript (or non-JSX) wouldn't typically do this. |
Thank you @ohanhi and @staltz for your comments. I presume you mean the way React makes look the same both arrays and single element, which is normal in HTML but confusing in JS indeed. So does it mean, this line in the Readme should be corrected?
|
Yes, I think adding the notion of "depending on your hyperscript library" could be helpful. |
@ohanhi Is there any library doing that? |
The Doc seems to allow passing single nodes as children but
when using with preact-hyperscript,
it seem that a single node can only be passed inside array:
See the pen here:
http://codepen.io/dmitriz/pen/qmqYgY?editors=0011
Also referred in queckezz/preact-hyperscript#7
in case it is a problem on their end.
It would be nice to provide this feature from the helpers even if the host library
h
does not (which is sadly often the case).The text was updated successfully, but these errors were encountered: