Options
All
  • Public
  • Public/Protected
  • All
Menu

Module DOMClient

Helpers for rendering in WaferClient

Index

Functions

Const apply

  • apply(el: Element, selector: string, func: (el: Element) => void): Promise<void>
  • Take a target DOM element and a selector to apply to that element and run a function on every match

    Parameters

    • el: Element

      target DOM element

    • selector: string

      CSS3 selector

    • func: (el: Element) => void

      function to run on all matches

        • (el: Element): void
        • Parameters

          • el: Element

          Returns void

    Returns Promise<void>

Const bindEvent

  • bindEvent(el: Element, selector: string, name: string, func: TargetEvent | ((ev: Event) => any)): void
  • Bind an event listener to a series of CSS selector matches in a DOM node

    Parameters

    • el: Element

      the element then listener should be attached to (unless overidden by specifying a different target in def)

    • selector: string

      the selector whose matches in el this event listener should be added

    • name: string

      the name of the event whose listener is being added

    • func: TargetEvent | ((ev: Event) => any)

      the listener being added, or a TargetEvent

    Returns void

Const emit

  • emit(target: Element, name: string, detail?: undefined | object, opts?: undefined | EventInit): void
  • Helper function for emitting DOM events

    Parameters

    • target: Element

      the element from which the event should be dispatched

    • name: string

      the event name

    • detail: undefined | object = {}
    • opts: undefined | EventInit = ...

    Returns void

Const repeat

  • repeat(__namedParameters: { container: Element; events: undefined | Object; html: string; init: undefined | null | ((el: Element, item?: any, index?: number) => void); items: any[]; keyFn: (value: any, index: number) => string; targets: undefined | Target[] }): Promise<void>
  • Utility to efficiently repeat and update a series of Elements into a container, taking in an html template from which the element will be stamped out, and a series of items and targets used to create and/or update elements

    Parameters

    • __namedParameters: { container: Element; events: undefined | Object; html: string; init: undefined | null | ((el: Element, item?: any, index?: number) => void); items: any[]; keyFn: (value: any, index: number) => string; targets: undefined | Target[] }
      • container: Element
      • events: undefined | Object
      • html: string
      • init: undefined | null | ((el: Element, item?: any, index?: number) => void)
      • items: any[]
      • keyFn: (value: any, index: number) => string
          • (value: any, index: number): string
          • Parameters

            • value: any
            • index: number

            Returns string

      • targets: undefined | Target[]

    Returns Promise<void>

Const stamp

  • stamp(html: string, firstChild?: undefined | boolean): Element | DocumentFragment
  • Stamp out an element from a string template

    Parameters

    • html: string

      The string template

    • firstChild: undefined | boolean = false

    Returns Element | DocumentFragment

    • The stamped out element

Generated using TypeDoc