sparc - v1.0.1
    Preparing search index...

    Abstract base class for rendering structured HTML elements with unique IDs, BEM-based class names, event management, and child support.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    _children?: HTMDNode
    _class: string
    _containerSelector: string

    should be ...but for the sake of simplicity, when undefined ill assign an empty string Pardon me for the incoherence and read the HTMDElementInterface docs on the same property

    _eventsMap: {} = {}
    _id: string
    _name: string

    Contains the lowercase class name. Used in to generate default class names and to classify the element type

    isHTMD: true

    Discriminator to identify classes that implement this interface

    isHTMDComponent

    Accessors

    • get class(): string
    • set class(classList: string): void

      A string containing all css classes attached to the element. Note that classes added via other methods will not be present here. Internally FormControls use modifierClasses, but external tools can also be used to add remove classes to the DOM. This is NOT the intended use.

      Setter method ensures that element classes are not removed

      Parameters

      • classList: string

      Returns void

      MyElement.class ="special-class"
      console.log(MyElement.class) //`${SPARC_PREFIX}__${this.name} special-class`
    • get id(): string

      By default an UUID is used. Can be overridden. This id can be used to identify both the object, and the DOM representation.

      Returns string

    • get name(): string

      Returns the lowercase class name responsible for creating this object. This property is used to define the element's main class too

      Returns string

    Methods

    • Replaces the DOM instance of this element with a re-rendered version.

      Parameters

      • shouldRenderChildren: boolean = true

        Whether to render child nodes.

      Returns void

    • Handles child rendering, removing existing nodes from the DOM, and rendering them inside this element.

      Parameters

      • children: undefined | HTMDNode = ...
      • Optionaloptions: { childContainerSelector?: string }

      Returns void

      const childContainerSelector = undefined // this.children -> rendered directly on this.instance
      const childContainerSelector = ".child-wrapper" // this.children -> rendered on this.instance.find(".child-wrapper")
    • Removes specified event handlers, or all if none are specified.

      Type Parameters

      • K extends keyof HTMLElementEventMap

      Parameters

      • OptionaleventsList: K | K[]

        An array of event types to clear (or a single type).

      Returns void

    • Registers an event handler for a given event type on this element. Replaces any previously assigned handler for the same event.

      Type Parameters

      • K extends keyof HTMLElementEventMap

      Parameters

      • eventName: K

        The DOM event type to listen for (e.g., 'click').

      • Optionalcallback: (ev: HTMLElementEventMap[K]) => void

        The event handler function.

      Returns void