update Vaadin to 25.2.6 (#95)
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s
Co-authored-by: Thomas Peetz <thomas.peetz@cimt-ag.de> Reviewed-on: #95
This commit was merged in pull request #95.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { injectGlobalCss } from 'Frontend/generated/jar-resources/theme-util.js';
|
||||
import { webcomponentGlobalCssInjector } from 'Frontend/generated/jar-resources/theme-util.js';
|
||||
let needsReloadOnChanges = false;
|
||||
|
||||
let themeRemovers = new WeakMap();
|
||||
let targets = [];
|
||||
const fontFaceRegex = /(@font-face\s*{[\s\S]*?})/g;
|
||||
|
||||
export const applyCss = (target) => {
|
||||
const removers = [];
|
||||
if (target !== document) {
|
||||
|
||||
webcomponentGlobalCssInjector((css) => {
|
||||
removers.push(injectGlobalCss(css, '', target));
|
||||
if(fontFaceRegex.test(css)) {
|
||||
const fontFaces = Array.from(css.match(fontFaceRegex));
|
||||
fontFaces.forEach(fontFace => {
|
||||
removers.push(injectGlobalCss(fontFace, '', document));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (import.meta.hot) {
|
||||
targets.push(new WeakRef(target));
|
||||
themeRemovers.set(target, removers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.accept((module) => {
|
||||
|
||||
if (needsReloadOnChanges) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
targets.forEach(targetRef => {
|
||||
const target = targetRef.deref();
|
||||
if (target) {
|
||||
themeRemovers.get(target).forEach(remover => remover())
|
||||
module.applyTheme(target);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
import.meta.hot.on('vite:afterUpdate', (update) => {
|
||||
document.dispatchEvent(new CustomEvent('vaadin-theme-updated', { detail: update }));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user