Trait yew::virtual_dom::VDiff

source ·
pub trait VDiff {
    type Context;
    type Component: Component<Self::Context>;

    fn detach(&mut self, parent: &Node) -> Option<Node>;
    fn apply(
        &mut self,
        parent: &Node,
        precursor: Option<&Node>,
        ancestor: Option<VNode<Self::Context, Self::Component>>,
        scope: &Activator<Self::Context, Self::Component>
    ) -> Option<Node>; }
Expand description

This trait provides features to update a tree by other tree comparsion.

Required Associated Types

The context where this instance live.

The component which this instance put into.

Required Methods

Remove itself from parent and return the next sibling.

Scoped diff apply to other tree.

Virtual rendering for the node. It uses parent node and existing children (virtual and DOM) to check the difference and apply patches to the actual DOM represenatation.

Parameters:

  • parent: the parent node in the DOM.
  • precursor: the “previous node” in a list of nodes, used to efficiently find where to put the node.
  • ancestor: the node that this node will be replacing in the DOM. This method will always remove the ancestor from the parent.
  • env: the Env.
Internal Behavior Notice:

Note that these modify the DOM by modifying the reference that already exists on the ancestor. If self.reference exists (which it shouldn’t) this method will panic.

The exception to this is obviously VRef which simply uses the inner Node directly (always removes the Node that exists).

Implementors