Swizz / snabbdom-pragma

'NotReact.createElement' jsx pragma although for snabbdom
MIT License
47 stars 16 forks source link

Does this handle svg automaticly? #1

Closed jvanbruegge closed 7 years ago

jvanbruegge commented 7 years ago

As this is my biggest pain point with snabbdom-jsx. If yes, I will switch to this one

Swizz commented 7 years ago

snabbdom-pragma is just a wrapper from React.createElement API to Snabbdom/h. So, all your jsx code will be transpiled to Snabbdom.createElement which call h.

Basically, if svg work with Snabbdom/h it will work with snabbdom-pragma BUT I will try with https://github.com/snabbdom/snabbdom/tree/master/examples/svg before giving you any final answer.

Swizz commented 7 years ago

Here we go !

You can look a small example here : Swizz/snabbdom-pragma-examples The working example : https://swizz.github.io/snabbdom-pragma-examples/ (interact with eyes)

It working fine, but snabbdom-pragma use the props module by default which is not compatible with the svg one. So, you need to use the attrs module.

You can use it by the following :

<circle attrs-cx="43.5" attrs-cy="23" attrs-r="5"/>

If this syntax isnt good to you, and you prefer choosing between the props or attrs module at start, I can improve this !

jvanbruegge commented 7 years ago

Why not set both? When using DOM Nodes only the props are used for updating. When using svg the attrs are used.

Swizz commented 7 years ago

Setting both at the same time ? Or do I need some conditionals for specifics svg tags ?

Swizz commented 7 years ago

In fact the attrs module seem greatest than the props one. I will consider to use attrs everywhere.

jvanbruegge commented 7 years ago

The problem is that attrs is not updating after the initial set. You will have to set both, but you shouldnt need any conditionals

Swizz commented 7 years ago

1.8.0 is now out ! And npm published.

I apologize for the delay.

jvanbruegge commented 7 years ago

Thanks