Skip to main content

Class: ClientWindow

@ima/core.ClientWindow

Client-side implementation of the Window utility API.

Hierarchy

Constructors

constructor

new ClientWindow()

Inherited from

Window.constructor

Properties

_scopedListeners

Private _scopedListeners: WeakMap<object, any>

Defined in

packages/core/src/window/ClientWindow.ts:11

Accessors

$dependencies

Static get $dependencies(): never[]

Returns

never[]

Defined in

packages/core/src/window/ClientWindow.ts:13

Methods

_addScopedListener

_addScopedListener(eventTarget, event, listener, useCapture?, scope?, usedListener?): void

Parameters

NameTypeDefault value
eventTargetEventTargetundefined
eventstringundefined
listener(event: Event) => voidundefined
useCapturebooleanfalse
scope?unknownundefined
usedListener?(event: Event) => voidundefined

Returns

void

Defined in

packages/core/src/window/ClientWindow.ts:288


_findScopedListener

_findScopedListener(eventTarget, event, listener, useCapture, scope, remove?): any

Parameters

NameTypeDefault value
eventTargetEventTargetundefined
eventstringundefined
listener(event: Event) => voidundefined
useCaptureboolean | ListenerOptionsundefined
scopeunknownundefined
removebooleanfalse

Returns

any

Defined in

packages/core/src/window/ClientWindow.ts:305


bindEventListener

bindEventListener(eventTarget, event, listener, useCapture?, scope?): void

Registers the provided event listener to be executed when the specified event occurs on the specified event target.

Registering the same event listener for the same event on the same event target with the same useCapture flag value repeatedly has no effect.

Parameters

NameTypeDefault valueDescription
eventTargetEventTargetundefinedThe event target.
eventstringundefinedThe name of the event.
listener(event: Event) => voidundefinedThe event listener.
useCapturebooleanfalseIf true, the method initiates event capture. After initiating capture, all events of the specified type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree. Events which are bubbling upward through the tree will not trigger a listener designated to use capture.
scope?unknownundefined-

Returns

void

Overrides

Window.bindEventListener

Defined in

packages/core/src/window/ClientWindow.ts:209


createCustomEvent

createCustomEvent(name, options): CustomEvent<unknown>

Create new instance of CustomEvent of the specified name and using the provided options.

See

https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent

Parameters

NameTypeDescription
namestringCustom event's name (sometimes referred to as the event's type).
optionsUnknownParametersThe custom event's options.

Returns

CustomEvent<unknown>

The created custom event.

Overrides

Window.createCustomEvent

Defined in

packages/core/src/window/ClientWindow.ts:202


getBody

getBody(): HTMLElement

Returns the document's body element. The method returns undefined if invoked at the server-side.

Returns

HTMLElement

The document's body element, or undefined if invoked at the server side.

Overrides

Window.getBody

Defined in

packages/core/src/window/ClientWindow.ts:142


getDocument

getDocument(): Document

Returns the native document object representing any web page loaded in the browser and serves as an entry point into the web page's content which is the DOM tree at the client-side. The method returns undefined if used at the server-side.

Returns

Document

The document object at the client-side, or undefined at the server-side.

Overrides

Window.getDocument

Defined in

packages/core/src/window/ClientWindow.ts:70


getDomain

getDomain(): string

Returns the domain of the current document's URL as ${protocol}://${host}.

Returns

string

The current domain.

Overrides

Window.getDomain

Defined in

packages/core/src/window/ClientWindow.ts:114


getElementById

getElementById(id): null | HTMLElement

Returns the HTML element with the specified id attribute value.

Parameters

NameTypeDescription
idstringThe value of the id attribute to look for.

Returns

null | HTMLElement

The element with the specified id, or null if no such element exists.

Overrides

Window.getElementById

Defined in

packages/core/src/window/ClientWindow.ts:149


getHistoryState

getHistoryState(): any

Returns the history state.

Returns

any

The current history state

Overrides

Window.getHistoryState

Defined in

packages/core/src/window/ClientWindow.ts:156


getHost

getHost(): string

Returns

string

The current host.

Overrides

Window.getHost

Defined in

packages/core/src/window/ClientWindow.ts:121


getPath

getPath(): string

Returns the path part of the current URL, including the query string.

Returns

string

The path and query string parts of the current URL.

Overrides

Window.getPath

Defined in

packages/core/src/window/ClientWindow.ts:128


getScrollX

getScrollX(): number

Returns the number of pixels the viewport is scrolled horizontally.

Returns

number

The number of pixels the viewport is scrolled horizontally.

Overrides

Window.getScrollX

Defined in

packages/core/src/window/ClientWindow.ts:77


getScrollY

getScrollY(): number

Returns the number of pixels the document is scrolled vertically.

Returns

number

The number of pixels the document is scrolled vertically.

Overrides

Window.getScrollY

Defined in

packages/core/src/window/ClientWindow.ts:92


getUrl

getUrl(): string

Returns

string

The current document's URL.

Overrides

Window.getUrl

Defined in

packages/core/src/window/ClientWindow.ts:135


getWindow

getWindow(): Window & typeof globalThis

Returns the native window object representing the global context at the client-side. The method returns undefined if used at the server-side.

Returns

Window & typeof globalThis

The window object at the client-side, or undefined at the server-side.

Overrides

Window.getWindow

Defined in

packages/core/src/window/ClientWindow.ts:63


hasSessionStorage

hasSessionStorage(): boolean

Returns true if the session storage is supported.

Returns

boolean

true if the session storage is supported.

Overrides

Window.hasSessionStorage

Defined in

packages/core/src/window/ClientWindow.ts:34


isClient

isClient(): boolean

Returns

boolean

true if invoked at the client side.

Overrides

Window.isClient

Defined in

packages/core/src/window/ClientWindow.ts:20


isCookieEnabled

isCookieEnabled(): boolean

Returns true if the cookies are set and processed with every HTTP request and response automatically by the environment.

Returns

boolean

true if cookies are handled automatically by the environment.

Overrides

Window.isCookieEnabled

Defined in

packages/core/src/window/ClientWindow.ts:27


pushState

pushState(state, title, url?): void

Pushes a new state to the browser history. The method has no effect if the current browser does not support the history API (IE9).

Parameters

NameTypeDescription
stateUnknownParametersA state object associated with the history item, preferably representing the page state.
titlestringThe page title related to the state. Note that this parameter is ignored by some browsers.
url?stringThe new URL at which the state is available.

Returns

void

Overrides

Window.pushState

Defined in

packages/core/src/window/ClientWindow.ts:184


querySelector

querySelector(selector): null | Element

Returns the first element matching the specified CSS 3 selector.

Parameters

NameTypeDescription
selectorstringThe CSS selector.

Returns

null | Element

The first element matching the CSS selector or null if no such element exists.

Overrides

Window.querySelector

Defined in

packages/core/src/window/ClientWindow.ts:163


querySelectorAll

querySelectorAll(selector): NodeListOf<Element>

Returns a node list of all elements matching the specified CSS 3 selector.

Parameters

NameTypeDescription
selectorstringThe CSS selector.

Returns

NodeListOf<Element>

A node list containing all elements matching the specified CSS selector.

Overrides

Window.querySelectorAll

Defined in

packages/core/src/window/ClientWindow.ts:170


redirect

redirect(url): void

Performs a hard redirect (discarding the current JavaScript state) to the specified URL.

Parameters

NameTypeDescription
urlstringThe URL to which the browser will be redirected.

Returns

void

Overrides

Window.redirect

Defined in

packages/core/src/window/ClientWindow.ts:177


replaceState

replaceState(state, title, url?): void

Replaces the current history entry. The method has no effect if the current browser does not support the history API (IE9).

Parameters

NameTypeDescription
stateUnknownParametersA state object associated with the history item, preferably representing the page state.
titlestringThe page title related to the state. Note that this parameter is ignored by some browsers.
url?stringThe new URL at which the state is available.

Returns

void

Overrides

Window.replaceState

Defined in

packages/core/src/window/ClientWindow.ts:193


scrollTo

scrollTo(x, y): void

Scrolls the viewport to the specified location (if possible).

Parameters

NameTypeDescription
xnumberHorizontal scroll offset in pixels.
ynumberVertical scroll offset in pixels.

Returns

void

Overrides

Window.scrollTo

Defined in

packages/core/src/window/ClientWindow.ts:107


setTitle

setTitle(title): void

Sets the new page title of the document.

Parameters

NameTypeDescription
titlestringThe new page title.

Returns

void

Overrides

Window.setTitle

Defined in

packages/core/src/window/ClientWindow.ts:56


unbindEventListener

unbindEventListener(eventTarget, event, listener, useCapture?, scope?): void

Deregisters the provided event listener, so it will no longer we executed when the specified event occurs on the specified event target.

The method has no effect if the provided event listener is not registered to be executed at the specified event.

Parameters

NameTypeDefault valueDescription
eventTargetEventTargetundefinedThe event target.
eventstringundefinedThe name of the event.
listener(event: Event) => voidundefinedThe event listener.
useCapturebooleanfalseThe useCapture flag value that was used when the listener was registered.
scope?unknownundefined-

Returns

void

Overrides

Window.unbindEventListener

Defined in

packages/core/src/window/ClientWindow.ts:249