Provides cross window checks for DOM nodes / elements, events, and essential duck typing for any class based object with a constructor name. The impetus is that certain browsers such as Chrome and Firefox behave differently when performing instanceof checks when elements are moved between browser windows. With Firefox in particular the entire JS runtime can not use instanceof checks as the instances of fundamental DOM elements differ between windows.

TRL supports moving applications from a main central browser window and popping them out into separate standalone app instances in a separate browser window. In this case for essential DOM element and event checks it is necessary to employ the workarounds found in CrossWindow.

Constructors

Methods

  • Convenience method to retrieve the document.activeElement value in the current Window context of a DOM Node / Element, EventTarget, Document, or Window.

    Parameters

    • target: EventTarget | Node | Document | Window | UIEvent

      DOM Node / Element, EventTarget, Document, UIEvent or Window to query.

    • Optionaloptions: { throws?: boolean }

      Options.

      • Optionalthrows?: boolean

        When true and target is invalid throw an exception. If false and the target is invalid undefined is returned; default: true.

    Returns Element

    Active element or undefined when throws option is false and the target is invalid.

    TypeError Target must be a DOM Node / Element, Document, UIEvent, or Window.

  • Convenience method to retrieve the Document value in the current context of a DOM Node / Element, EventTarget, Document, UIEvent, or Window.

    Parameters

    • target: EventTarget | Node | Document | Window | UIEvent

      DOM Node / Element, EventTarget, Document, UIEvent or Window to query.

    • Optionaloptions: { throws?: boolean }

      Options.

      • Optionalthrows?: boolean

        When true and target is invalid throw an exception. If false and the target is invalid undefined is returned; default: true.

    Returns Document

    Active document or undefined when throws option is false and the target is invalid.

    TypeError Target must be a DOM Node / Element, Document, UIEvent, or Window.

  • Convenience method to retrieve the Window value in the current context of a DOM Node / Element, EventTarget, Document, or Window.

    Parameters

    • target: EventTarget | Node | Document | Window | UIEvent

      DOM Node / Element, EventTarget, Document, UIEvent or Window to query.

    • Optionaloptions: { throws?: boolean }

      Options.

      • Optionalthrows?: boolean

        When true and target is invalid throw an exception. If false and the target is invalid undefined is returned; default: true.

    Returns Window

    Active window or undefined when throws option is false and the target is invalid.

    TypeError Target must be a DOM Node / Element, Document, UIEvent, or Window.

  • Provides basic type checking by constructor name(s) for objects. This can be useful when checking multiple constructor names against a provided Set.

    Parameters

    • target: unknown

      Object to test for constructor name.

    • types: string | Set<string>

      Specific constructor name or Set of constructor names to match.

    Returns boolean

    Does the provided object constructor name match the types provided.

  • Provides basic prototype string type checking if target is a Document.

    Parameters

    • target: unknown

      A potential Document to test.

    Returns target is Document

    Is target a Document.

  • Provides precise type checking if target is a DocumentFragment.

    Parameters

    • target: unknown

      A potential DocumentFragment to test.

    Returns target is DocumentFragment

    Is target a DocumentFragment.

  • Provides precise type checking if target is an Element.

    Parameters

    • target: unknown

      A potential Element to test.

    Returns target is Element

    Is target an Element.

  • Provides basic duck type checking for Event signature and optional constructor name(s).

    Parameters

    • target: unknown

      A potential DOM event to test.

    • Optionaltypes: string | Set<string>

      Specific constructor name or Set of constructor names to match.

    Returns target is Event

    Is target an Event with optional constructor name check.

  • Ensures that the given target is an instanceof all known DOM elements that are focusable. Please note that additional checks are required regarding focusable state; use A11yHelper.isFocusable for a complete check.

    Parameters

    • target: unknown

      Target to test for instanceof focusable HTML element.

    Returns boolean

    Is target an instanceof a focusable DOM element.

  • Provides precise type checking if target is a HTMLAnchorElement.

    Parameters

    • target: unknown

      A potential HTMLAnchorElement to test.

    Returns target is HTMLAnchorElement

    Is target a HTMLAnchorElement.

  • Provides precise type checking if target is a HTMLElement.

    Parameters

    • target: unknown

      A potential HTMLElement to test.

    Returns target is HTMLElement

    Is target a HTMLElement.

  • Provides basic prototype string type checking if target is a Map.

    Parameters

    • target: unknown

      A potential Map to test.

    Returns target is Map<any, any>

    Is target a Map.

  • Provides precise type checking if target is a Node.

    Parameters

    • target: unknown

      A potential Node to test.

    Returns target is Node

    Is target a DOM Node.

  • Provides basic duck type checking for Event signature for standard mouse / pointer events including MouseEvent and PointerEvent.

    Parameters

    • target: unknown

      A potential DOM event to test.

    Returns target is PointerEvent

    Is target a MouseEvent or PointerEvent.

  • Provides basic prototype string type checking if target is a Promise.

    Parameters

    • target: unknown

      A potential Promise to test.

    Returns target is Promise<any>

    Is target a Promise.

  • Provides basic prototype string type checking if target is a RegExp.

    Parameters

    • target: unknown

      A potential RegExp to test.

    Returns target is RegExp

    Is target a RegExp.

  • Provides basic prototype string type checking if target is a Set.

    Parameters

    • target: unknown

      A potential Set to test.

    Returns target is Set<any>

    Is target a Set.

  • Provides precise type checking if target is a ShadowRoot.

    Parameters

    • target: unknown

      A potential ShadowRoot to test.

    Returns target is ShadowRoot

    Is target a ShadowRoot.

  • Provides precise type checking if target is a SVGElement.

    Parameters

    • target: unknown

      A potential SVGElement to test.

    Returns target is SVGElement

    Is target a SVGElement.

  • Provides basic prototype string type checking if target is a URL.

    Parameters

    • target: unknown

      A potential URL to test.

    Returns target is URL

    Is target a URL.

  • Provides basic duck type checking for Event signature for standard user input events including KeyboardEvent, MouseEvent, and PointerEvent.

    Parameters

    • target: unknown

      A potential DOM event to test.

    Returns target is PointerEvent | MouseEvent | KeyboardEvent

    Is target a Keyboard, MouseEvent, or PointerEvent.

  • Provides basic prototype string type checking if target is a Window.

    Parameters

    • target: unknown

      A potential Window to test.

    Returns target is Window

    Is target a Window.