crysalead-js / dom-layer

Virtual DOM implementation.
MIT License
30 stars 1 forks source link

overall bug cause throwing #36

Closed ghost closed 9 years ago

ghost commented 9 years ago

After 1 hour hard testing i found out that you need to verify if it's plain object you are playing with, or a dom-layer object. Else dom-layer will throw, or sometimes fuck up things very bad.

Example: h({ tagName:"div", }, [h({tagName:"div"}, [{foo: "bar"}])]

This code will throw this TypeError: childNode.render is not a function

Solution to the problem is simple, and need to be done all over the code if you don't want dom-layer to throw.

Solution:

In the create() function, check for type on the object, example: if(container.type){}

The code will not throw anymore.

ghost commented 9 years ago

I checked with Virtual DOM and they got some IS-functions they are using for this.

jails commented 9 years ago

If it wouldn't throw any error, you wouldn't get notified that your virtual tree is invalid. And I think it's important to warn the user sooner that what he is doing is wrong.