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

pub trait VDiff {
    fn detach(&mut self, parent: &Element) -> Option<Node>;
fn apply(
        &mut self,
        parent: &Element,
        previous_sibling: Option<&Node>,
        ancestor: Option<VNode>
    ) -> Option<Node>; }

This trait provides features to update a tree by calculating a difference against another tree.

Required methods

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

Remove itself from parent and return the next sibling.

fn apply(
    &mut self,
    parent: &Element,
    previous_sibling: Option<&Node>,
    ancestor: Option<VNode>
) -> 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 representation.

Parameters:

  • parent: the parent node in the DOM.
  • previous_sibling: 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.
  • parent_scope: the parent Scope used for passing messages to the parent Component.

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 VDiff for VNode[src]

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

Remove VNode from parent.

impl VDiff for VComp[src]

impl VDiff for VList[src]

impl VDiff for VTag[src]

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

Remove VTag from parent.

fn apply(
    &mut self,
    parent: &Element,
    previous_sibling: Option<&Node>,
    ancestor: Option<VNode>
) -> 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 VDiff for VText[src]

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

Remove VText from parent.

fn apply(
    &mut self,
    parent: &Element,
    previous_sibling: Option<&Node>,
    ancestor: Option<VNode>
) -> Option<Node>
[src]

Renders virtual node over existing TextNode, but only if value of text had changed.

Loading content...