Jelajahi Sumber

fixed loading issue on Firefox

Gildas 7 tahun lalu
induk
melakukan
3d90dc0542
2 mengubah file dengan 8 tambahan dan 2 penghapusan
  1. 1 1
      lib/single-file/css-minifier.js
  2. 7 1
      lib/single-file/rules-matcher.js

+ 1 - 1
lib/single-file/css-minifier.js

@@ -28,7 +28,7 @@ this.cssMinifier = this.stylesMinifier || (() => {
 
 	return {
 		process: doc => {
-			const rulesMatcher = new RulesMatcher(doc);
+			const rulesMatcher = RulesMatcher.create(doc);
 			const mediaAllInfo = rulesMatcher.getAllMatchedRules();
 			const stats = { processed: 0, discarded: 0 };
 			doc.querySelectorAll("style").forEach(styleElement => {

+ 7 - 1
lib/single-file/rules-matcher.js

@@ -25,7 +25,7 @@ this.RulesMatcher = this.RulesMatcher || (() => {
 	const MEDIA_ALL = "all";
 	const PRIORITY_IMPORTANT = "important";
 
-	return class {
+	class RulesMatcher {
 		constructor(doc) {
 			this.doc = doc;
 			this.mediaAllInfo = createMediaInfo(MEDIA_ALL);
@@ -51,6 +51,12 @@ this.RulesMatcher = this.RulesMatcher || (() => {
 		getMatchedRules(element) {
 			this.mediaAllInfo.elements.get(element);
 		}
+	}
+
+	return {
+		create(doc) {
+			return new RulesMatcher(doc);
+		}
 	};
 
 	function getMatchedElementsRules(doc, cssRules, mediaInfo, sheetIndex) {