1
0
Эх сурвалжийг харах

delete stylesheets, styles, and CSS var objects once serialized

Gildas 7 жил өмнө
parent
commit
8252de39e1

+ 4 - 0
lib/single-file/single-file-core.js

@@ -1032,6 +1032,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 			this.doc.querySelectorAll("style").forEach(styleElement => {
 				const stylesheetInfo = this.stylesheets.get(styleElement);
 				if (stylesheetInfo) {
+					this.stylesheets.delete(styleElement);
 					let stylesheetContent = cssTree.generate(stylesheetInfo.stylesheet);
 					styleElement.textContent = stylesheetContent;
 					if (stylesheetInfo.mediaText) {
@@ -1044,6 +1045,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 			this.doc.querySelectorAll("link[rel*=stylesheet]").forEach(linkElement => {
 				const stylesheetInfo = this.stylesheets.get(linkElement);
 				if (stylesheetInfo) {
+					this.stylesheets.delete(linkElement);
 					const styleElement = this.doc.createElement("style");
 					if (stylesheetInfo.mediaText) {
 						styleElement.media = stylesheetInfo.mediaText;
@@ -1061,6 +1063,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 			this.doc.querySelectorAll("[style]").forEach(async element => {
 				const declarations = this.styles.get(element);
 				if (declarations) {
+					this.styles.delete(element);
 					let styleContent = cssTree.generate(declarations);
 					element.setAttribute("style", styleContent);
 				} else {
@@ -1080,6 +1083,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 				}
 				let stylesheetContent = "";
 				this.cssVariables.forEach((content, indexResource) => {
+					this.cssVariables.delete(indexResource);
 					if (stylesheetContent) {
 						stylesheetContent += ";";
 					}