run method

void run()

Implementation

void run() {
  if (debug != null) {
    kDEBUG = debug!;
  }

  if (target != null) {
    final element = document.querySelector(target!);
    if (element == null) {
      throw Exception('Element with id $target not found');
    }

    if (style != null) {
      final styleString = style!.entries
          .map((entry) => "${entry.key}: ${entry.value};")
          .join(" ");

      element.setAttribute('style', styleString);
    }

    if (className != null) {
      element.className = className!;
    }

    if (children != null) {
      for (final child in children!) {
        element.append(child.render());
      }
    }

    if (title != null) {
      document.title = title!;
    }

    if (onRender != null) {
      onRender!(document);
    }
  }
}