render method

  1. @override
Element render()
override

Creates an HTML Element represention of Component.

Implementation

@override
Element render() {
  HTMLElement? element;

  if (isExternal == true) {
    element = document.createElement('div') as HTMLTemplateElement;
    element.attachShadow(ShadowRootInit(mode: "open"));

    for (final resource in resources!) {
      if (resource['type'] == 'css') {
        final link = document.createElement('link') as HTMLLinkElement;
        link.rel = 'stylesheet';
        link.href = resource['url'] as String;
        element.shadowRoot!.append(link);
      } else if (resource['type'] == 'js') {
        final script = document.createElement('script') as HTMLScriptElement;
        script.src = resource['url'] as String;
        element.shadowRoot!.append(script);
      }
    }
  } else {
    element = document.createElement('div') as HTMLDivElement;
  }

  element.innerHTML = rawHtml.toJS;

  return element;
}