renderNew method

  1. @override
void renderNew(
  1. VNode? parent
)
override

Renders the newly created virtual node.

Implementation

@override
void renderNew(VNode? parent) {
  renderSafely(() {
    this.parent = parent;
    final node1 = document.createElement(tagName);
    if (isShadowRootUsed) {
      _shadowRoot = node1.attachShadow(const {'mode': 'open'});
    }

    for (final key in attributes.keys) {
      final value = attributes[key]!;
      if (value != false) {
        node1.setAttribute(key, value);
      }
    }

    for (final key in listeners.keys) {
      final listener = listeners[key];
      final wrapper = wrapListener(listener);
      node1.addEventListener(key, wrapper);
    }

    for (final entry in children) {
      final child = entry.vNode;
      child.renderNew(parent);
      final node = child.node!;
      if (isShadowRootUsed) {
        shadowRoot!.append(node);
      } else {
        node1.append(node);
      }
    }

    node = node1;
  });
}