3 ms·
This is a reference implementation, you can easily implement it by using React or any other virtual DOM lib. All components would work as well.
by boris_m 3y ago
This is a reference implementation, you can easily implement it by using React or any other virtual DOM lib. All components would work as well.
- tobr 3y agoNot sure I see how. Components appear to return DOM nodes, but as far as I can see they’re not provided an existing DOM structure to inspect. So they can’t be sure how to safely reuse existing DOM, as they don’t control what the parent will do with the nodes they return.
- boris_m 3y agoNo, I mean to reimplement the "framework". 1. Change the "div" "span" etc. to be just "createElement('div'..." 2. At the "render" function, do "reactDOM.render" instead of "replaceChildren"
- tobr 3y agoI think I misunderstood what you’re trying to do, in that case. This is a pattern for how to handle state updates, rather than a framework that happens to not have any code.
- boris_m 3y agoIt was mainly a demonstration of a pattern, yes, implementation was a secondary consideration. But there are ways to make this approach work as well.