render method

  1. @override
VNode render(
  1. VNode newVNode,
  2. bool canDispose
)
override

Renders an existing (this) virtual node or a newly created newVNode node.

If the existing node and the newly created node are equivalent, then the existing node is rendered, otherwise a new node is rendered, replacing the existing node.

Rendering an existing node does not necessarily mean an actual rendering.

For example, if an existing VComponent node is rendered that does not need to be rendered, no action will be taken.

Implementation

@override
VNode render(VNode newVNode, bool canDispose) {
  return renderSafely(() {
    if (VNode.isEqual(this, newVNode)) {
      rebuild(newVNode, canDispose);
      return this;
    } else {
      newVNode.renderAndReplace(parent, node!);
      if (canDispose) {
        dispose();
      }

      return newVNode;
    }
  });
}