-
-
Notifications
You must be signed in to change notification settings - Fork 37
Is it a normal behavior to have all element properties stringified (through hast-to-hyperscript) ? #41
Comments
Hi @medfreeman, thanks for the thorough details! Am I correct in assuming this is an issue with For a solution, I’m thinking |
@wooorm Thanks for your really quick answer ! I wasn't sure if it was an abnormal behavior in hast-to-hyperscript or remark-react, since i don't understand all the finer points, but that makes sense. About react vdom, i'm looking into this right now. |
About React's VDOM and non-strings in normal html elements, i'm not sure of the exact answer, but i'm getting a pretty good idea of how the thing works after a few hours of reading doc / looking at react's code. |
Please go to sleep! 💤 This can wait! |
The answer is basically yes, but the processing differs depending on the node / attribute:
References in order: Differences with html attributes
|
I don't know if everything will be of use to you, but i hope i've been concise enough ! |
This is really awesome! I’m working on better props tests, and support for this, but that may take a while depending on how it goes (I’ve got a busy week unfortunately)! |
Thanks ! Can you explain what part of this hast-to-hyperscript has to support ? |
So the current tests were focussed on creating the same tree through However, I found that to be a bit buggy when I was rewriting the tests: now I’m going:
|
ok i understand ! thanks for your work !! i'll use coercition in the mean time ! do not hesitate to ask if you need a bit of help, i can certainly spare a few hours during the next days. |
...and add better tests Related to remarkjs/remark-react/issues/41.
I’ve pushed a new version to |
Add `transformToReact` helper using `react-test-renderer` Add `babel-preset-react` for transpiling JSX Add `react` devDependency Add `Icon` mock react component Comment boolean prop test while waiting for [`remark-react`](https://github.com/mapbox/remark-react) and [`hast-to-hyperscript`](https://github.com/syntax-tree/hast-to-hyperscript) to be updated in remarkjs/remark-react#41 Ignore main function statement as it seems not covered in specific cases...
Add `transformToReact` helper using `react-test-renderer` Add `babel-preset-react` for transpiling JSX Add `react` devDependency Add `Icon` mock react component Comment boolean prop test while waiting for [`remark-react`](https://github.com/mapbox/remark-react) and [`hast-to-hyperscript`](https://github.com/syntax-tree/hast-to-hyperscript) to be updated in remarkjs/remark-react#41 Ignore main function statement as it seems not covered in specific cases...
Should i just make a PR updating |
Yeah! |
Fixes broken coercion of props values Fixes remarkjs#41
Hi, thanks for your work !!
here's a bit of context.
I'm developing a common mark generic extensions plugin, supporting this kind of syntax:
!Element[content](argument){ properties }
I'm using
!Icon[My-tooltip](my-icon){ floating }
for testingMy remark inline tokenizer returns this node:
Notice the boolean property named
floating
.I can properly have my corresponding react component
TooltipIcon
render with the following snippet (es6):Whereas my
floating
property is effectively boolean inside the HAST tree generated by remark, it is stringified by hast-to-hyperscript at this line, called here in remark-react.In order to avoid a react
PropTypes
type warning, i'm actually forced to also allowString
in addition toBoolean
propTypes for thefloating
property inside my component. I then coerce thefloating
property back to boolean, in order for the subcomponent (which requiresfloating
to be boolean) to be happy.Here's my TooltipIcon component:
I hope you get the general idea, and if you can tell if it's a requirement to have every property stringified.
Because in this case only
String
properties can be passed to React if i'm not mistaken.The text was updated successfully, but these errors were encountered: