Skip to content

@jimka/typescript-ui / core / StyleTarget

Class: abstract StyleTarget<T>

Defined in: src/typescript/lib/core/StyleTarget.ts:19

Shared base for a deferred-write style buffer. Either flushes into a CSSStyleRule (see StyleRule) or an HTMLElement (see InlineStyle).

Remarks

Before the target exists, writes accumulate in dirty. Once materialize runs, queued entries flush onto the target's style declaration and subsequent StyleTarget.set calls write through directly. StyleTarget.queue is a write-to-dirty-only path used by callers that need to batch their own commits (see Component's autoCommitStyle switch).

Extended by

Type Parameters

T extends { style: CSSStyleDeclaration; }

Constructors

new StyleTarget()

ts
new StyleTarget<T>(): StyleTarget<T>

Returns

StyleTarget<T>

Methods

flush()

ts
flush(): void

Defined 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


isMaterialized()

ts
isMaterialized(): boolean

Defined in: src/typescript/lib/core/StyleTarget.ts:85

Returns whether the underlying target has been materialised.

Returns

boolean


queue()

ts
queue(key: string, value: null | string): void

Defined 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


queueMany()

ts
queueMany(values: Record<string, null | string>): void

Defined 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


set()

ts
set(key: string, value: null | string): void

Defined 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


setMany()

ts
setMany(values: Record<string, null | string>): void

Defined 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