deact function

Deact deact(
  1. String selector,
  2. RootNodeProvider root
)

The entrypoint to mount a Deact application to the DOM.

The application will be mounted beneath the elements selected by the given selector. All node beneath that element will be deleted and replaced by the root node.

Implementation

Deact deact(String selector, RootNodeProvider root) {
  // query the host element
  final hostElement = html.querySelector(selector);
  if (hostElement == null) {
    throw ArgumentError('no element found for selector $selector');
  }

  final rootNode = RootNode._(selector, hostElement, root);
  final rootLocation = _TreeLocation(null, rootNode, _NodeType.root, '"$selector"', 0);

  // create the deact instance
  final deact = _DeactInstance(rootLocation);

  // Initial render of the Deact node hierarchy.
  _renderInstance(deact);

  return deact;
}