- Version
- 1.0.0
- License
- MIT
- Requires
- object
- sortElements
- DomSmith
- domSmithInputRange
- domSmithSelect
- domSmithTooltip
- Source
- Dom.js, line 29
Constructor
new Dom(player, parent, optionsopt)
Creates an instance of the Dom component. Also prepares the root dom element based on the player config.
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
player |
Player |
Reference to the VisionPlayer instance. |
|||||||||
parent |
Player |
Reference to the parent instance. |
|||||||||
options |
Object | optional |
Additional options.
|
- Throws
-
If trying to disable this component.
Type Error
Members
private #config :Object
Holds the instance configuration for this component.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
shadow
|
'open' | 'closed' | '' | optional | '' | Shadow DOM mode: |
className
|
string | optional | '' | Sets a custom classname on the player instance. |
insertMode
|
'auto' | 'replace' | 'append' | 'before' | optional | 'auto' | Where |
darkMode
|
'dark' | 'light' | 'auto' | optional | 'dark' | Sets the preferred visual mode for the player: |
layout
|
string | optional | '' | Activates special layout modes. Currently supported: |
aspectRatio
|
number | string | optional | 16/9 | Defines the aspect ratio of the player. Can be a numeric value like |
aspectRatioTransitions
|
boolean | optional | false | If |
width
|
number | string | optional | 100% | Optional fixed width. If set as a number, it will be interpreted as pixels. If set as a string, it will be passed as-is to the CSS (e.g. |
height
|
number | string | optional | '' | Optional fixed height. If set as a number, it will be interpreted as pixels. If set as a string, it will be passed as-is to the CSS (e.g. |
_targetEle
|
HTMLElement | optional nullable | null | The original target element calculated or received from the first |
private #player :Player
private #subscriptions :Array<number>
Holds tokens of subscriptions to player events, for later unsubscribe.
private #apiKey :symbol
Secret key only known to the player instance and initialized components. Used to be able to restrict access to API methods in conjunction with secure mode.
private #dom :HTMLElement
private #targetEle :HTMLElement
private #shadow :ShadowRoot
private #wrapper :HTMLElement
Reference to the top-level wrapper node, which will be used when shado wmode is active.
private #styleEles :Map<string, HTMLStyleElement>
Map holding all style elements for live updates (key: style id/url, value: <style> node).
private, static #styles :Map<string, string>
Global map holding all loaded style contents (key: absolute style path, value: CSS).
private, static #instances :Set<Dom>
Methods
private #initStyles()
private #refresh()
Called - via private API - from the player class if all components have been reloaded due to a config change. Resorts the root Dom and fires events again so components can catch up.
- Fires
- dom/ready
- dom/beforemount
- Source
- Dom.js, line 315
private #mount()
Inserts the root dom element into the host document.
- Fires
- dom/ready
- dom/beforemount
- Source
- Dom.js, line 329
private #getElement(apiKey) → HTMLElement
Used by child components to retrieve the player root element. Access is restricted by apiKey if secure mode is enabled.
| Name | Type | Description |
|---|---|---|
apiKey |
symbol |
Token needed to grant access in secure mode. |
updateStyles(styles)
Updates the content of all style elements in this instance using the provided array of style objects. Used for live HMR updates.
| Name | Type | Description |
|---|---|---|
styles |
Array<{key: string, css: string}> |
Array of style updates (key: style id/url, css: new content). |
destroy()
Cleans up the Dom component by unsubscribing from events and removing style elements.
static initialize(Player)
Registers API hooks on the Player class for style injection and HMR update.
| Name | Type | Description |
|---|---|---|
Player |
Player |
Reference to the Player constructor. |
private, static #addStyles(path, css)
Adds a style sheet to the global styles map (used by all player instances).
| Name | Type | Description |
|---|---|---|
path |
string |
Relative or absolute style path (e.g., |
css |
string |
Raw CSS string (usually imported with ?inline). |
private, static #updateStyles(styles)
Triggers an updateStyles call on all Dom instances, used for HMR.
| Name | Type | Description |
|---|---|---|
styles |
Array<{key: string, css: string}> |
Array of updated styles (key/url, css string). |
Events
dom/beforemount
This event is fired when the player has initialized all components, but is not added to the DOM yet.
- Listeners
- Controller#sortButtons
- Source
- Dom.js, line 446
dom/ready
This event is fired when the player was just added to the target DOM.
- Listeners
- Scrubber#onDomReady
- UI#onDomReady
- Source
- Dom.js, line 451