diff --git a/src/shared/style-manager.ts b/src/shared/style-manager.ts index d9504ed..a45fd07 100644 --- a/src/shared/style-manager.ts +++ b/src/shared/style-manager.ts @@ -82,15 +82,20 @@ export class StyleManager { }; item.count++; this.themeMap.set(theme.name, item); - if (!item.styleNode && isBrowser) { - item.styleNode = document.createElement('style'); - document.head.append(item.styleNode); - } if (!item.className) { item.className = CLASSNAME_UNIQUE + '_' + theme.name; } + if (!item.styleNode && isBrowser) { + item.styleNode = document.createElement('style'); + try { + this.styleNode?.before(item.styleNode); + } catch (error) { + console.warn(`insert theme [${item.className}] error:`, error); + } + } + const themeCss = `.${item.className}{${themeToCss(theme)}}`; item.css = themeCss;