Class CrossWindow
Index
Constructors
Methods
Constructors
constructor
- new CrossWindow(): CrossWindow
Returns CrossWindow
Methods
Static
getActiveElement
- getActiveElement(
target: EventTarget | Node | Document | Window | UIEvent,
options?: { throws?: boolean },
): Element 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.
Optional
options: { throws?: boolean }Options.
Returns Element
Active element or
undefined
whenthrows
option isfalse
and the target is invalid.- target: EventTarget | Node | Document | Window | UIEvent
Static
getDocument
- getDocument(
target: EventTarget | Node | Document | Window | UIEvent,
options?: { throws?: boolean },
): Document 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.
Optional
options: { throws?: boolean }Options.
Returns Document
Active document or
undefined
whenthrows
option isfalse
and the target is invalid.- target: EventTarget | Node | Document | Window | UIEvent
Static
getWindow
- getWindow(
target: EventTarget | Node | Document | Window | UIEvent,
options?: { throws?: boolean },
): 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.
Optional
options: { throws?: boolean }Options.
Returns Window
Active window or
undefined
whenthrows
option isfalse
and the target is invalid.- target: EventTarget | Node | Document | Window | UIEvent
Static
isCtorName
- isCtorName(target: unknown, types: string | Set<string>): boolean
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.
- target: unknown
Static
isDocument
Static
isDocumentFragment
- isDocumentFragment(target: unknown): target is DocumentFragment
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.- target: unknown
Static
isElement
Static
isEvent
- isEvent(target: unknown, types?: string | Set<string>): target is Event
Provides basic duck type checking for
Event
signature and optional constructor name(s).Parameters
- target: unknown
A potential DOM event to test.
Optional
types: 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.- target: unknown
Static
isFocusableHTMLElement
- isFocusableHTMLElement(target: unknown): boolean
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.- target: unknown
Static
isHTMLAnchorElement
- isHTMLAnchorElement(target: unknown): target is HTMLAnchorElement
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.- target: unknown
Static
isHTMLElement
- isHTMLElement(target: unknown): target is HTMLElement
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.- target: unknown
Static
isMap
Static
isNode
Static
isPointerEvent
- isPointerEvent(target: unknown): target is PointerEvent
Provides basic duck type checking for
Event
signature for standard mouse / pointer events includingMouseEvent
andPointerEvent
.Parameters
- target: unknown
A potential DOM event to test.
Returns target is PointerEvent
Is
target
a MouseEvent or PointerEvent.- target: unknown
Static
isPromise
Static
isRegExp
Static
isSet
Static
isShadowRoot
- isShadowRoot(target: unknown): target is ShadowRoot
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.- target: unknown
Static
isSVGElement
- isSVGElement(target: unknown): target is SVGElement
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.- target: unknown
Static
isUIEvent
Static
isURL
Static
isUserInputEvent
- isUserInputEvent(
target: unknown,
): target is PointerEvent | MouseEvent | KeyboardEvent Provides basic duck type checking for
Event
signature for standard user input events includingKeyboardEvent
,MouseEvent
, andPointerEvent
.Parameters
- target: unknown
A potential DOM event to test.
Returns target is PointerEvent | MouseEvent | KeyboardEvent
Is
target
a Keyboard, MouseEvent, or PointerEvent.- target: unknown
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 useinstanceof
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
.