Class: DomPatcher

DomPatcher()

Handles patching the DOM with new HTML content using a simple diffing algorithm. This approach is more efficient than innerHTML as it preserves existing DOM nodes.

Constructor

new DomPatcher()

Source:

Methods

applyDirectives(element, resolveExpression, appopt)

Recursively applies custom directives to an element and its children.

Parameters:
Name Type Attributes Description
element Element

The element tree root.

resolveExpression function

The expression evaluator.

app object <optional>

The application context.

Source:

applyDirectivesInternal(element, resolveExpression, appopt)

Recursively applies directives to an element and its children.

Parameters:
Name Type Attributes Description
element Element

The target element.

resolveExpression function

Expression resolver callback.

app object <optional>

The application context.

Source:

cleanElement(element) → {Element}

Cleans an element by removing boolean attributes that evaluate to false.

Parameters:
Name Type Description
element Element

The element to clean.

Source:
Returns:

The cleaned element.

Type
Element

enter(el, transitionName)

Applies the enter transition classes and triggers animation/transition.

Parameters:
Name Type Description
el Element

The element to animate.

transitionName string

The transition name (e.g. 'fade').

Source:

flattenTransitionTags(node)

Flattens elements inside a root element.

Parameters:
Name Type Description
node Element

The root element.

Source:

flushLifecycleHooks(app)

Flushes all lifecycle hooks collected during the patch session.

Parameters:
Name Type Description
app object
Source:

getTransitionName(el, resolveExpressionopt) → {string|null}

Resolves the transition name for an element.

Parameters:
Name Type Attributes Description
el Element

The element.

resolveExpression function <optional>

The expression evaluator.

Source:
Returns:

The resolved transition name, or null.

Type
string | null

isNodeInPatchTree(el) → {boolean}

Checks if a node is in the currently patched DOM tree.

Parameters:
Name Type Description
el Element
Source:
Returns:
Type
boolean

leave(el, transitionName, removeCallback)

Applies the leave transition classes, triggers animation, and cleans up when complete.

Parameters:
Name Type Description
el Element

The element to animate.

transitionName string

The transition name (e.g. 'fade').

removeCallback function

Callback invoked when the leave transition completes.

Source:

patch(target, html, resolveExpressionopt, appopt)

Patches the target element with the provided HTML.

Parameters:
Name Type Attributes Description
target Element

The element to patch.

html string

The new HTML content.

resolveExpression function <optional>

Function to evaluate expressions.

app object <optional>

The application context.

Source:

patchElement(oldElement, newElement, resolveExpressionopt, appopt)

Patches an existing element with a new element structure in-place.

Parameters:
Name Type Attributes Description
oldElement Element

The existing element.

newElement Element

The new element structure.

resolveExpression function <optional>

Function to evaluate expressions.

app object <optional>

The application context.

Source:

triggerEnter(el, resolveExpressionopt)

Triggers the enter transition if transition configurations are present.

Parameters:
Name Type Attributes Description
el Element

The element.

resolveExpression function <optional>

The expression evaluator.

Source:

triggerLeave(el, resolveExpression, removeCallback, appopt)

Triggers the leave transition or asynchronous unmounting of an element.

Parameters:
Name Type Attributes Description
el Element

The element leaving.

resolveExpression function

Expression evaluator callback.

removeCallback function

Callback to remove element from DOM.

app object <optional>

The application context.

Source:

triggerUnmounted(node, app)

Triggers the unmounted hook recursively on a node and its descendants.

Parameters:
Name Type Description
node Node
app object
Source:

triggerUnmountedForElement(el, app)

Triggers the unmounted hook on a single element.

Parameters:
Name Type Description
el Element
app object
Source: