Closed ghost closed 9 years ago
I checked with Virtual DOM and they got some IS-functions they are using for this.
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.
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.