wavesoft / dot-dom

.dom is a tiny (512 byte) template engine that uses virtual DOM and some of react principles
Apache License 2.0
806 stars 53 forks source link

Does not handle children that are numbers #31

Open SilentCicero opened 7 years ago

SilentCicero commented 7 years ago

Does not nicely handle vnode instances which are numbers, only strings. Maybe if type number => render to string.

wavesoft commented 7 years ago

Ouch, that's indeed a tricky one. I will try to find a good solution for this, but right now it's not easy, since I am relying on string's properties to identify it.

jhnns commented 5 years ago

Imo that's not a big limitation. I think it's fair to assume that numbers need to be casted to strings by components. The same problem also exists for null and false which are valid render values in React. Both the null and the false case can be expressed as "" which I think is fine.

mindplay-dk commented 4 years ago

For the record, we're talking about these lines here, right?

I'm wondering, can we simply reverse the test and the condition?

So instead of vnode.replace, how about e.g. !!vnode.a?

This should match anything that's not a vnode object, including strings, numbers and booleans, right?

(if that works, also maybe swap the terminals of the ternary expression and save one of the ! operators.)

mindplay-dk commented 2 years ago

I think we can close this?

mindplay-dk commented 2 years ago

...although it's still on a devel branch that might should be merged back to master?