|
|
@@ -806,10 +806,15 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
insertVariables() {
|
|
|
if (this.cssVariables.size) {
|
|
|
const styleElement = this.doc.createElement("style");
|
|
|
- if (this.doc.head.firstChild) {
|
|
|
- this.doc.head.insertBefore(styleElement, this.doc.head.firstChild);
|
|
|
+ const firstStyleElement = this.doc.head.querySelector("style");
|
|
|
+ if (firstStyleElement) {
|
|
|
+ this.doc.head.insertBefore(styleElement, firstStyleElement);
|
|
|
} else {
|
|
|
- this.doc.head.appendChild(styleElement);
|
|
|
+ if (this.doc.head.firstChild) {
|
|
|
+ this.doc.head.insertBefore(styleElement, this.doc.head.firstChild);
|
|
|
+ } else {
|
|
|
+ this.doc.head.appendChild(styleElement);
|
|
|
+ }
|
|
|
}
|
|
|
let stylesheetContent = "";
|
|
|
this.cssVariables.forEach((content, indexResource) => {
|