Options
All
  • Public
  • Public/Protected
  • All
Menu

The builder handles the initialization of the HTML content of the Custom Element.

The content can be provided as a string value or a factory function (c.f. ContentFactory) when the builder is created with ContentBuilder.get.

By default, the builder injects the content as children of the Custom Element into the Light DOM on the lifecycle callback connectedCallback. However, the builder can inject the content within the Shadow DOM with ContentBuilder.shadow.

Finally, the builder can be registered using the method ElementBuilder.builder of the main builder (i.e. ElementBuilder). However, it can also be registered with the decorative style using the decorator ContentBuilder.decorate.

Type parameters

  • E: HTMLElement = HTMLElement

    the type of the Custom Element

Hierarchy

  • ContentBuilder

Implements

  • Builder<E>

Index

Constructors

Private constructor

Methods

Protected build

  • build(Constructor: CustomElementConstructor<E>, hooks: HooksRegistration<E & { __ceb_content_default_html?: string }>): void
  • This API is dedicated for developer of Builders.

    Parameters

    • Constructor: CustomElementConstructor<E>
    • hooks: HooksRegistration<E & { __ceb_content_default_html?: string }>

    Returns void

decorate

  • decorate(): ClassDecorator
  • Decorate the Custom Element class.

    example
    import {ElementBuilder} from "@tmorin/ceb-elements-core"
    import {ContentBuilder} from "@tmorin/ceb-elements-builders"
    @ElementBuilder.get<HelloWorld>().decorate()
    @ContentBuilder.get(`Hello, World!`).decorate()
    class HelloWorld extends HTMLElement {
    }

    Returns ClassDecorator

shadow

  • Forces the content injection into the Shadow DOM.

    example
    import {ElementBuilder} from "@tmorin/ceb-elements-core"
    import {ContentBuilder} from "@tmorin/ceb-elements-builders"
    class HelloWorld extends HTMLElement {
    }
    ElementBuilder.get().builder(
    ContentBuilder.get(`Hello, World!`).shadow()
    ).register()

    Parameters

    • Optional focus: boolean

      when true, the focus is delegated to the shadow DOM

    Returns ContentBuilder<E>

Static get

Generated using TypeDoc