wijjit.core.reconciler.Reconciler
- class wijjit.core.reconciler.Reconciler(registry)[source]
Reconciles old and new VNode trees, producing a patched Element tree.
The Reconciler implements a React-style diffing algorithm that:
Compares old and new VNode trees
Identifies what changed (creates, deletes, updates)
Patches existing Elements in place where possible
Creates new Elements only when necessary
Preserves ephemeral state (cursor, scroll, selection) across re-renders, while letting a template deliberately drive it: a controllable ephemeral prop whose bound value changed this render is applied over the preserved snapshot (“state wins, else preserve”). See
_diff_controlled_ephemeral().
- Parameters:
registry (
ElementRegistry) – Registry for creating new Element instances- Variables:
registry (
ElementRegistry) – Element factory registry_element_cache (
dict) – Cache of key -> Element for reusing elements
Examples
>>> from wijjit.core.vdom import VNode >>> from wijjit.core.element_registry import ElementRegistry >>> registry = ElementRegistry() >>> reconciler = Reconciler(registry) >>> old_tree = VNode.create("Button", key="btn", props={"label": "Old"}) >>> new_tree = VNode.create("Button", key="btn", props={"label": "New"}) >>> root, elements = reconciler.reconcile(old_tree, new_tree) >>> root.label # Element was updated, not replaced 'New'
- __init__(registry)[source]
- Parameters:
registry (ElementRegistry)
- Return type:
None
Methods
__init__(registry)Clear the element cache.
get_cached_element(key)Get an element from the cache by key.
reconcile(old_tree, new_tree)Reconcile old and new VNode trees.
- reconcile(old_tree, new_tree)[source]
Reconcile old and new VNode trees.
- Parameters:
- Returns:
(root_element, flat_element_list) - root_element: Root Element of the tree (None if new_tree is None) - flat_element_list: Flattened list of all Elements for event handling
- Return type: