Sfoglia il codice sorgente

global cache to store matched rules

Gildas 7 anni fa
parent
commit
222906d368
1 ha cambiato i file con 3 aggiunte e 2 eliminazioni
  1. 3 2
      lib/single-file/single-file-core.js

+ 3 - 2
lib/single-file/single-file-core.js

@@ -359,10 +359,11 @@ this.SingleFileCore = (() => {
 
 		removeUnusedCSSRules() {
 			const doc = this.doc;
+			const rulesCache = {};
 			doc.querySelectorAll("style").forEach(style => {
 				const cssRules = [];
 				if (style.sheet) {
-					DomProcessorHelper.processRules(this.doc, style.sheet.cssRules, cssRules);
+					DomProcessorHelper.processRules(this.doc, style.sheet.cssRules, cssRules, rulesCache);
 					const stylesheetContent = cssRules.join("");
 					style.textContent = this.options.compressCSS ? this.dom.uglifycss(stylesheetContent) : stylesheetContent;
 				}
@@ -688,7 +689,7 @@ this.SingleFileCore = (() => {
 			}));
 		}
 
-		static processRules(doc, rules, cssRules, cache = {}) {
+		static processRules(doc, rules, cssRules, cache) {
 			if (rules) {
 				Array.from(rules).forEach(rule => {
 					if (rule.media) {