Class StyleManager
Implements
- Iterable<[string, RuleManager]>
Index
Accessors
Methods
Accessors
isConnected
- get isConnected(): boolean
Determines if this StyleManager style element is still connected / available.
Returns boolean
Is StyleManager connected.
textContent
- get textContent(): string
Returns string
Provides an accessor to get the
textContent
for the style sheet.
version
- get version(): string
Returns string
Returns the version of this instance.
Methods
[iterator]
- "[iterator]"(): MapIterator<[string, RuleManager]>
Allows usage in
for of
loops directly.Returns MapIterator<[string, RuleManager]>
Entries Map iterator.
clone
- clone(options: Clone): StyleManager
Provides a copy constructor to duplicate an existing StyleManager instance into a new document.
Parameters
- options: Clone
Required clone options.
Returns StyleManager
New style manager instance or undefined if not connected.
- options: Clone
entries
- entries(): MapIterator<[string, RuleManager]>
Returns MapIterator<[string, RuleManager]>
RuleManager entries iterator.
get
- get(ruleName: string): RuleManager
Retrieves an associated RuleManager by name.
Parameters
- ruleName: string
Rule name.
Returns RuleManager
Associated rule manager for given name or undefined if the rule name is not defined or manager is unconnected.
- ruleName: string
has
keys
- keys(): MapIterator<string>
Returns MapIterator<string>
RuleManager keys iterator.
values
- values(): MapIterator<RuleManager>
Returns MapIterator<RuleManager>
Iterator of all RuleManager instances.
Static
connect
- connect(options: Connect): StyleManager
Connect to an existing dynamic styles managed element by CSS ID with semver check on version range compatibility.
Parameters
- options: Connect
Options.
Returns StyleManager
- options: Connect
Static
create
- create(options: StyleManager.Options.Create): StyleManager
Parameters
- options: StyleManager.Options.Create
Options.
Returns StyleManager
Created style manager instance or undefined if already exists with a higher version.
- options: StyleManager.Options.Create
Static
exists
- exists(options: StyleManager.Options.Exists): StyleManager.Data.Exists
Query and check for an existing dynamic style manager element / instance given a CSS ID.
Parameters
- options: StyleManager.Options.Exists
Options.
Returns StyleManager.Data.Exists
Undefined if no style manager is configured for the given CSS ID otherwise an object containing the current version and HTMLStyleElement associated with the CSS ID.
- options: StyleManager.Options.Exists
Provides a managed dynamic style sheet / element useful in configuring global CSS variables. When creating an instance of StyleManager, you must provide a CSS ID for the style element.
Instances of StyleManager must be versioned by supplying a semver version string via the 'version' option. This version is assigned to the associated style element. When a StyleManager instance is created and there is an existing instance with a version that is lower than the current new instance, all CSS rules are removed, letting the higher version take precedence. This isn't a perfect system and requires thoughtful construction of CSS variables exposed, but allows multiple independently compiled TRL packages to load the latest CSS variables..