kbrsh / moon

🌙 The minimal & fast library for functional user interfaces
https://moonjs.org
MIT License
6k stars 200 forks source link

virtual DOM and diff ? #239

Closed yisar closed 6 years ago

yisar commented 6 years ago

I've seen moonjs trigger data changes with updateand recompile view, Although it is accurate enough, but is it virtual DOM and diff not better?

kbrsh commented 6 years ago

Moon used to use a virtual DOM. Now, it compiles views into direct JavaScript code — it is never "recompiled". Virtual DOM works by creating an abstraction over the normal DOM. When a change is made, Moon used to iterate through the new virtual DOM, compare it with the old virtual DOM, and use normal DOM operations to update the view.

With v1, instead of having to have the abstraction of the virtual DOM, Moon directly generates the normal DOM operations instead.