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 work well with spreads #5

Closed SilentCicero closed 7 years ago

SilentCicero commented 7 years ago

This doesn't seem to be possible:

function createElement(tag, props, children) {
  return global.H(tag, props, ...children);
}

The result:

Object {E: "apply", P: Window, Symbol(): 1}
E:
"apply"
P:
Window
Symbol():
1
__proto__:
Object

It is assuming apply is a component, when it is not.

wavesoft commented 7 years ago

Hello @SilentCicero and thank you for your comments. I bet you are using babel, right?

This is not really an issue with the spread itself, but with the transformation since it becomes H.apply (this, [].concat (tag, props, children) and therefore becomes a tag shorthand syntax.

This library is not really meant to be used with babel polyfills.

SilentCicero commented 7 years ago

Right, I understand, but I think you should maybe offer a npm/babel way to benefit from this module. We dont want this hard work to go to waste on just IoT devices.

SilentCicero commented 7 years ago

Can you give an example or way for me to do this without babel transform spread operator?

wavesoft commented 7 years ago

I will actually create an NPM polyfil module that implements some of the functionality needed in order to integrate this with babel 👍

wavesoft commented 7 years ago

What would that do is prohibit apply from being forwarded to the Proxy object 😄

SilentCicero commented 7 years ago

Why dont you just restrict apply conditionally. That way we can just use spreads properly.

wavesoft commented 7 years ago

@SilentCicero I wanted to keep the library core intact and build around the existing structures - if possible.

This is now related to #4 and the general "npm-ization" process of the library so I am going to close this issue.