(content: string, name: string, value = "", theme?: string)
| 27 | }; |
| 28 | |
| 29 | const updateStyle = (content: string, name: string, value = "", theme?: string) => { |
| 30 | if (isSSR) { |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | const currentRuntimeIndex = getCurrentRuntimeIndex(); |
| 35 | |
| 36 | const stylesheet = document.adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === getStyleId(name, value)); |
| 37 | if (!stylesheet) { |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | if (!theme) { |
| 42 | stylesheet.replaceSync(content || ""); |
| 43 | } else { |
| 44 | const stylesheetRuntimeIndex: string | undefined = (stylesheet as Record<string, any>)._ui5RuntimeIndex; |
| 45 | const stylesheetTheme: string | undefined = (stylesheet as Record<string, any>)._ui5Theme; |
| 46 | if (stylesheetTheme !== theme || shouldUpdate(stylesheetRuntimeIndex)) { |
| 47 | stylesheet.replaceSync(content || ""); |
| 48 | (stylesheet as Record<string, any>)._ui5RuntimeIndex = String(currentRuntimeIndex); |
| 49 | (stylesheet as Record<string, any>)._ui5Theme = theme; |
| 50 | } |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | const hasStyle = (name: string, value = ""): boolean => { |
| 55 | if (isSSR) { |
no test coverage detected
searching dependent graphs…