@gluonjs/core / src/styles / StyleSheetSelectionEntry
Interface: StyleSheetSelectionEntry
Extended by
Properties
id
readonlyid:string
Stable transport identity. Content changes are detected by the digest.
scope?
readonlyoptionalscope?:string
Optional owner namespace used to isolate hydration carriers.
sheet
readonlysheet:CSSStyleSheet
Example
Associate one constructed sheet with its stable transport ID and optional hydration scope:
import {
createStyleSheetOwner,
createStyleSheetSelection,
css,
getStyleSheetDigest,
getStyleTextDigest,
replaceStyleSheet,
type StyleSheetOwner,
type StyleSheetSelection,
type StyleSheetSelectionEntry,
} from '@gluonjs/core';
const sheet = css`:root { --shop-accent: blue; }`;
const entry = { id: 'shop-theme', scope: 'shop', sheet } satisfies StyleSheetSelectionEntry;
const selection: StyleSheetSelection = createStyleSheetSelection([entry]);
const owner: StyleSheetOwner = createStyleSheetOwner(document);
owner.retain(sheet);
replaceStyleSheet(sheet, ':root { --shop-accent: green; }');
console.log(selection.entries[0]?.id, getStyleSheetDigest(sheet), getStyleTextDigest('shop'));
owner.release(sheet);
owner.dispose();