jj
    Preparing search index...

    Function customEvent

    • Creates a CustomEvent with JJ's default bubbling and Shadow DOM settings.

      Type Parameters

      • T = unknown

      Parameters

      • type: string

        The event type name.

      • Optionaldetail: T

        Optional payload exposed as event.detail.

      • Optionaloptions: Omit<CustomEventInit<T>, "detail">

        Additional CustomEvent options excluding detail.

      Returns CustomEvent<T>

      A configured CustomEvent instance.

      Native CustomEvent defaults to bubbles: false and composed: false. JJ defaults both to true because cross-component custom events commonly need to bubble out of Shadow DOM boundaries.

      Pass options to override those defaults when you need a local-only event.

      If eventName is not a string.

      const event = customEvent('todo-toggle', { id: '123', done: true })
      element.dispatchEvent(event)
      const localOnly = customEvent('panel-ready', undefined, {
      bubbles: false,
      composed: false,
      })