(theme: string)
| 58 | }; |
| 59 | |
| 60 | const attachCustomThemeStylesToHead = async (theme: string): Promise<void> => { |
| 61 | const link = document.querySelector(`[sap-ui-webcomponents-theme="${theme}"]`); |
| 62 | |
| 63 | if (link) { |
| 64 | document.head.removeChild(link); |
| 65 | } |
| 66 | |
| 67 | const themeRoot = getThemeRoot(); |
| 68 | |
| 69 | if (!themeRoot) { |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | const validatedThemeRoot = validateThemeRoot(themeRoot); |
| 74 | |
| 75 | if (!validatedThemeRoot) { |
| 76 | console.warn(`The ${themeRoot} is not valid. Check the allowed origins as suggested in the "setThemeRoot" description.`); // eslint-disable-line |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | await createLinkInHead(formatThemeLink(theme, validatedThemeRoot), { "sap-ui-webcomponents-theme": theme }); |
| 81 | }; |
| 82 | |
| 83 | export { |
| 84 | getThemeRoot, |
no test coverage detected
searching dependent graphs…