MCPcopy Create free account
hub / github.com/UI5/webcomponents / createStyle

Function createStyle

packages/base/src/ManagedStyles.ts:16–27  ·  view source on GitHub ↗
(content: string, name: string, value = "", theme?: string)

Source from the content-addressed store, hash-verified

14};
15
16const createStyle = (content: string, name: string, value = "", theme?: string) => {
17 const currentRuntimeIndex = getCurrentRuntimeIndex();
18
19 const stylesheet = new CSSStyleSheet();
20 stylesheet.replaceSync(content);
21 (stylesheet as Record<string, any>)._ui5StyleId = getStyleId(name, value); // set an id so that we can find the style later
22 if (theme) {
23 (stylesheet as Record<string, any>)._ui5RuntimeIndex = currentRuntimeIndex;
24 (stylesheet as Record<string, any>)._ui5Theme = theme;
25 }
26 document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
27};
28
29const updateStyle = (content: string, name: string, value = "", theme?: string) => {
30 if (isSSR) {

Callers 1

createOrUpdateStyleFunction · 0.85

Calls 2

getCurrentRuntimeIndexFunction · 0.85
getStyleIdFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…