Document Object Model (DOM)
This is the tree of nodes.
Learned in CS349.
Virtual DOM
The VDOM is a lightweight representation of the UI in memory.
Purpose
Used for two purposes:
- “Render” an actual DOM using imperative methods
- Lightweight abstraction of DOM to compare changes
The VDOM is synchronized with the “real” DOM as follows:
- Save current VDOM
- Components and/or application state updates the VDOM
- A re-render is triggered by framework
- Compare VDOM before update with VDOM after update
- Reconcile the difference identifying a set of DOM patches
- Perform patch operations on real DOM
- Back to step 1
Hyperscript function calls create a representation of UI tree
- It’s a JavaScript object
- Commonly referred to as a virtual DOM (or just “vdom”)
Used for two purposes:
- “Render” an actual DOM using imperative methods
- Lightweight abstraction of DOM to compare changes