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

Function attachCustomThemeStylesToHead

packages/base/src/config/ThemeRoot.ts:60–81  ·  view source on GitHub ↗
(theme: string)

Source from the content-addressed store, hash-verified

58};
59
60const 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
83export {
84 getThemeRoot,

Callers 2

detectExternalThemeFunction · 0.85
setThemeRootFunction · 0.85

Calls 5

validateThemeRootFunction · 0.85
createLinkInHeadFunction · 0.85
formatThemeLinkFunction · 0.85
removeChildMethod · 0.80
getThemeRootFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…