Class: ClientWindow
@ima/core.ClientWindow
Client-side implementation of the Window utility API.
Hierarchy
↳
ClientWindow
Constructors
constructor
• new ClientWindow()
Inherited from
Properties
#scopedListeners
• Private
#scopedListeners: WeakMap
<object
, any
>
Defined in
packages/core/src/window/ClientWindow.ts:10
Accessors
$dependencies
• Static
get
$dependencies(): never
[]
Returns
never
[]
Defined in
packages/core/src/window/ClientWindow.ts:12
Methods
_findScopedListener
▸ Private
_findScopedListener<T
, E
, S
>(eventTarget
, event
, listener
, options
, scope
, remove?
): any
Type parameters
Name | Type |
---|---|
T | extends EventTarget |
E | extends Event |
S | S |
Parameters
Name | Type | Default value |
---|---|---|
eventTarget | T | undefined |
event | string | undefined |
listener | (event : E ) => void | undefined |
options | boolean | AddEventListenerOptions | undefined |
scope | S | undefined |
remove | boolean | false |
Returns
any
Defined in
packages/core/src/window/ClientWindow.ts:297
bindEventListener
▸ bindEventListener<T
, E
, S
>(eventTarget
, event
, listener
, options?
, 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.
Type parameters
Name | Type |
---|---|
T | extends EventTarget |
E | extends Event |
S | S |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
eventTarget | T | undefined | The event target. |
event | string | undefined | The name of the event. |
listener | (event : E ) => void | undefined | The event listener. |
options | boolean | EventListenerOptions | false | - |
scope? | S | undefined | - |
Returns
void
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:213
createCustomEvent
▸ createCustomEvent<T
>(name
, options
): CustomEvent
<T
>
Create new instance of CustomEvent of the specified name and using the provided options.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
name | string | Custom event's name (sometimes referred to as the event's type). |
options | CustomEventInit <T > | The custom event's options. |
Returns
CustomEvent
<T
>
The created custom event.
See
https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:203
getBody
▸ getBody(): undefined
| HTMLElement
Returns the document's body element. The method returns
undefined
if invoked at the server-side.
Returns
undefined
| HTMLElement
The document's body element, or
undefined
if invoked at the server side.
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:141
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
Defined in
packages/core/src/window/ClientWindow.ts:69
getDomain
▸ getDomain(): string
Returns the domain of the current document's URL as
${protocol}://${host}
.
Returns
string
The current domain.
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:113
getElementById
▸ getElementById(id
): null
| HTMLElement
Returns the HTML element with the specified id
attribute value.
Parameters
Name | Type | Description |
---|---|---|
id | string | The 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
Defined in
packages/core/src/window/ClientWindow.ts:148
getHistoryState
▸ getHistoryState(): any
Returns the history state.
Returns
any
The current history state
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:155
getHost
▸ getHost(): string
Returns
string
The current host.
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:120
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
Defined in
packages/core/src/window/ClientWindow.ts:127
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
Defined in
packages/core/src/window/ClientWindow.ts:76
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
Defined in
packages/core/src/window/ClientWindow.ts:91
getUrl
▸ getUrl(): string
Returns
string
The current document's URL.
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:134
getWindow
▸ getWindow(): Window
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
The window
object at the
client-side, or undefined
at the server-side.
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:62
hasSessionStorage
▸ hasSessionStorage(): boolean
Returns true
if the session storage is supported.
Returns
boolean
true
if the session storage is supported.
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:33
isClient
▸ isClient(): boolean
Returns
boolean
true
if invoked at the client side.
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:19
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
Defined in
packages/core/src/window/ClientWindow.ts:26
pushState
▸ pushState<T
>(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).
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
state | T | A state object associated with the history item, preferably representing the page state. |
title | string | The page title related to the state. Note that this parameter is ignored by some browsers. |
url? | string | The new URL at which the state is available. |
Returns
void
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:185
querySelector
▸ querySelector<E
>(selector
): null
| E
Returns the first element matching the specified CSS 3 selector.
Type parameters
Name | Type |
---|---|
E | extends Element = Element |
Parameters
Name | Type | Description |
---|---|---|
selector | string | The CSS selector. |
Returns
null
| E
The first element matching the CSS selector or
null
if no such element exists.
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:162
querySelectorAll
▸ querySelectorAll<E
>(selector
): NodeListOf
<E
>
Returns a node list of all elements matching the specified CSS 3 selector.
Type parameters
Name | Type |
---|---|
E | extends Element = Element |
Parameters
Name | Type | Description |
---|---|---|
selector | string | The CSS selector. |
Returns
NodeListOf
<E
>
A node list containing all elements matching the specified CSS selector.
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:169
redirect
▸ redirect(url
): void
Performs a hard redirect (discarding the current JavaScript state) to the specified URL.
Parameters
Name | Type | Description |
---|---|---|
url | string | The URL to which the browser will be redirected. |
Returns
void
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:178
replaceState
▸ replaceState<T
>(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).
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
state | T | A state object associated with the history item, preferably representing the page state. |
title | string | The page title related to the state. Note that this parameter is ignored by some browsers. |
url? | string | The new URL at which the state is available. |
Returns
void
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:194
scrollTo
▸ scrollTo(x
, y
): void
Scrolls the viewport to the specified location (if possible).
Parameters
Name | Type | Description |
---|---|---|
x | number | Horizontal scroll offset in pixels. |
y | number | Vertical scroll offset in pixels. |
Returns
void
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:106
setTitle
▸ setTitle(title
): void
Sets the new page title of the document.
Parameters
Name | Type | Description |
---|---|---|
title | string | The new page title. |
Returns
void
Overrides
Defined in
packages/core/src/window/ClientWindow.ts:55
unbindEventListener
▸ unbindEventListener<T
, E
, S
>(eventTarget
, event
, listener
, options?
, scope?
): void
Deregister 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.
Type parameters
Name | Type |
---|---|
T | extends EventTarget |
E | extends Event = Event |
S | any |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
eventTarget | T | undefined | The event target. |
event | string | undefined | The name of the event. |
listener | (event : E ) => void | undefined | The event listener. |
options | boolean | EventListenerOptions | false | The useCapture flag value that was used when the listener was registered, or provide capture option through object options. |
scope? | S | undefined | - |
Returns
void