update method

void update()

Forces a re-render of the component.

Implementation

void update() {
  if (!isHydrated) return;

  // On the browser, styles are already applied via adoptedStyleSheets in onMount().
  // We only need the build() result, not the style element, to avoid CSP issues
  // with dynamically created <style> tags that wouldn't have a nonce.

  // Set the event wrapper hook so events are wrapped during VDOM construction
  // instead of traversing the tree afterwards.
  final prevWrapper = html.Element.eventWrapper;
  html.Element.eventWrapper = _wrapHandler;

  List<html.Node> newVdom;
  try {
    newVdom = [build()];
  } finally {
    html.Element.eventWrapper = prevWrapper;
  }

  final root = shadowRoot;
  if (root != null) {
    vdom.mountList(root, newVdom);
  } else {
    vdom.mountList(element, newVdom);
  }
}