@jimka/typescript-ui / core / StyleRule
Class: StyleRule
Defined in: src/typescript/lib/core/StyleTarget.ts:128
Deferred-write buffer that materialises into a per-component CSSStyleRule the first time StyleRule.ensure is called.
Remarks
The rule factory is invoked lazily so detached construction incurs no stylesheet insertion. Once materialised, the rule object is stable for the lifetime of this StyleRule.
Inherited StyleTarget.set queues writes into a dirty bag while the target is null and writes through once ensure() has materialised the rule. Owners that need the rule on the stylesheet at first render (rather than at first write) register the rule via Component's registerStyleRule, which calls ensure() from applyStyle and flushes the dirty bag onto the live CSSStyleRule.
Extends
StyleTarget<CSSStyleRule>
Constructors
new StyleRule()
new StyleRule(factory: () => CSSStyleRule): StyleRuleDefined in: src/typescript/lib/core/StyleTarget.ts:131
Parameters
factory
() => CSSStyleRule
Returns
Overrides
Methods
ensure()
ensure(): CSSStyleRuleDefined in: src/typescript/lib/core/StyleTarget.ts:140
Materialises the underlying CSSStyleRule on first access and returns it. Pending dirty entries are flushed in the same call.
Returns
CSSStyleRule
flush()
flush(): voidDefined in: src/typescript/lib/core/StyleTarget.ts:74
Drains the dirty bag onto the live target. No-op when the target is not yet attached — the dirty entries stay queued for the next flush after materialize.
Returns
void
Inherited from
isMaterialized()
isMaterialized(): booleanDefined in: src/typescript/lib/core/StyleTarget.ts:85
Returns whether the underlying target has been materialised.
Returns
boolean
Inherited from
queue()
queue(key: string, value: null | string): voidDefined in: src/typescript/lib/core/StyleTarget.ts:56
Writes a single style property into the dirty bag without flushing, even when the target is already attached. Callers that own their own batching gate (e.g. autoCommitStyle = false) use this to accumulate writes that StyleTarget.flush will drain later.
Parameters
key
string
The CSS property name (camelCase).
value
The value to set, or null to remove the property.
null | string
Returns
void
Inherited from
queueMany()
queueMany(values: Record<string, null | string>): voidDefined in: src/typescript/lib/core/StyleTarget.ts:65
Bulk variant of StyleTarget.queue.
Parameters
values
Record<string, null | string>
Camel-cased property keys mapped to string values (or null to clear).
Returns
void
Inherited from
set()
set(key: string, value: null | string): voidDefined in: src/typescript/lib/core/StyleTarget.ts:30
Writes a single style property. Flushes immediately when the target is attached; otherwise queues the entry into the dirty bag.
Parameters
key
string
The CSS property name (camelCase).
value
The value to set, or null to remove the property.
null | string
Returns
void
Inherited from
setMany()
setMany(values: Record<string, null | string>): voidDefined in: src/typescript/lib/core/StyleTarget.ts:43
Bulk variant of StyleTarget.set.
Parameters
values
Record<string, null | string>
Camel-cased property keys mapped to string values (or null to clear).
Returns
void