[][src]Trait yew::virtual_dom::VDiff

pub trait VDiff {
    type Component: Component;
    fn detach(&mut self, parent: &Node) -> Option<Node>;
fn apply(
        &mut self,
        parent: &Node,
        precursor: Option<&Node>,
        ancestor: Option<VNode<Self::Component>>,
        scope: &Scope<Self::Component>
    ) -> Option<Node>; }

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

Associated Types

type Component: Component

The component which this instance put into.

Loading content...

Required methods

fn detach(&mut self, parent: &Node) -> Option<Node>

Remove itself from parent and return the next sibling.

fn apply(
    &mut self,
    parent: &Node,
    precursor: Option<&Node>,
    ancestor: Option<VNode<Self::Component>>,
    scope: &Scope<Self::Component>
) -> Option<Node>

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).

Loading content...

Implementors

impl<COMP> VDiff for VComp<COMP> where
    COMP: Component + 'static, 
[src]

type Component = COMP

fn detach(&mut self, parent: &Node) -> Option<Node>[src]

Remove VComp from parent.

fn apply(
    &mut self,
    parent: &Node,
    precursor: Option<&Node>,
    ancestor: Option<VNode<Self::Component>>,
    env: &Scope<Self::Component>
) -> Option<Node>
[src]

Renders independent component over DOM Element. It also compares this with an ancestor VComp and inherits sender of it.

impl<COMP: Component> VDiff for VNode<COMP>[src]

type Component = COMP

fn detach(&mut self, parent: &Node) -> Option<Node>[src]

Remove VNode from parent.

impl<COMP: Component> VDiff for VList<COMP>[src]

type Component = COMP

impl<COMP: Component> VDiff for VTag<COMP>[src]

type Component = COMP

fn detach(&mut self, parent: &Node) -> Option<Node>[src]

Remove VTag from parent.

fn apply(
    &mut self,
    parent: &Node,
    precursor: Option<&Node>,
    ancestor: Option<VNode<Self::Component>>,
    env: &Scope<Self::Component>
) -> Option<Node>
[src]

Renders virtual tag over DOM Element, but it also compares this with an ancestor VTag to compute what to patch in the actual DOM nodes.

impl<COMP: Component> VDiff for VText<COMP>[src]

type Component = COMP

fn detach(&mut self, parent: &Node) -> Option<Node>[src]

Remove VTag from parent.

fn apply(
    &mut self,
    parent: &Node,
    _: Option<&Node>,
    opposite: Option<VNode<Self::Component>>,
    _: &Scope<Self::Component>
) -> Option<Node>
[src]

Renders virtual node over existent TextNode, but only if value of text had changed. Parameter precursor is necesssary for VTag and VList which has children and renders them.

Loading content...