Skip to content

Commit

Permalink
fix: theme style node order
Browse files Browse the repository at this point in the history
  • Loading branch information
daief committed May 21, 2023
1 parent 0202bb0 commit e48eedf
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/shared/style-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit e48eedf

Please sign in to comment.