Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HTMLComponent

This class generally shouldn't need to be extended as we should have all HTML components already implemented as specialisations of this class.

Hierarchy

Index

Constructors

  • arg

    children The constructor takes in an argument that can either be a string, ComponentTree, or undefined If a string is provided, it will be set as the innerText of this.element. If a ComponentTree is provided, it will be rendered and mounted to this.element. If it is left undefined, nothing will be mounted to this.element

    Parameters

    Returns HTMLComponent

Properties

_initialised: boolean = false
children?: string | ComponentTree
element: Element = ...

This holds the components root element, for a HTMLComponent, this would be the Button or paragraph tag, or for a Component, this is the containing div.

The _render method should mount any child elements to this element, so it should be safe to set this before its rendered.

Methods

  • _init(parent: Element | ShadowRoot): void
  • This method is used to initalise the component. It calls the _render method and mounts this.element to the parent element passed to it.

    Parameters

    • parent: Element | ShadowRoot

    Returns void

  • _render(): void
  • _setElement(element: Element): void
  • rerender(): void
  • This method should be called when the content inside the component has been updated. The most juniour component that needs to be updated should be called to help performance.

    For example, if you have the choice of rerendering a parent or its child, if the visual update only concerns the child, then calling rerender on the child is prefered.

    Returns void

Generated using TypeDoc