Harmless

    Class JSXElement<T>Abstract

    Base class for JSX elements.

    Type Parameters

    Index

    Constructors

    Properties

    context: null | Context = null

    The component context.

    Methods

    • Returns Node

    • Destroys the component scope and all its child scopes. Called when the connected HTML element has been removed from the DOM.

      Returns void

    • Renders this JSX element.

      Returns T | Promise<T>

      The created JSX element.

    • Renders this JSX element.

      Returns T | Promise<T>

      The created JSX element.

    • Renders this JSX element synchronously. Throws an error when it encounters a promise.

      Returns T

      The created JSX element.

    • Recursively resolves a child which can be one of the following types:

      • null or undefined. Is resolved into an empty text node.
      • An already resolved DOM node. Nothing needs to be resolved in this case.
      • A JSX element. The element is rendered into a HTML element.
      • A promise. A temporary empty text node is created and replaced with the real node later.
      • An observable. Initially a new empty node is created, the observable is subscribed and then the current node is replaced with the new one every time a new value has been emitted by the observable. Observing stops when the node is garbage-collected or the observable reports an error or completes.
      • A function. It is called (without parameters) and then the returned value is recursively resolved into a node.
      • Any other value. It is converted to a string and wrapped into a text node.

      Parameters

      • source: unknown

        The source to resolve.

      Returns Node

      The created node which can be inserted into the DOM.

    • Resolves a child from an observable. It creates an initial temporary empty text node which can be added to the DOM immediately. This node is replaced later with a real node when the observable emits its first value. And then on each new emitted value the current node is replaced again with a new node, until the observable is canceled by an error or completes. The observable is automatically unsubscribed when a new value is emitted but the node generated for the previous element has been garbage-collected.

      Parameters

      • source: Subscribable

        The observable to subscribe to.

      Returns Node

      Initial empty text node which is replaced with the first real node as soon as available and then updated every time a new value is emitted.

    • Resolves a child from a promise. It creates a temporary empty text node which can be added to the DOM immediately. Then the promise is resolved asynchronously to the real node which then replaces the temporary node.

      Parameters

      • source: Promise<unknown>

        The promise to resolve.

      Returns Node

      Temporary empty text node which is replaced with the real node as soon as available.

    • Runs the given function within the elements signal scope which is created when not already present.

      Type Parameters

      • T

      Parameters

      • fn: () => T

        The function to run in the signal scope.

      Returns T

      The function result.

    MMNEPVFCICPMFPCPTTAAATR