Kaynağa Gözat

don't try to recover invalid font-face rules

Gildas 7 yıl önce
ebeveyn
işleme
8b3bfb03de
1 değiştirilmiş dosya ile 6 ekleme ve 10 silme
  1. 6 10
      lib/single-file/single-file-core.js

+ 6 - 10
lib/single-file/single-file-core.js

@@ -1229,7 +1229,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 
 			async function processFontFaceRule(cssRule) {
 				await Promise.all(cssRule.block.children.toArray().map(async declaration => {
-					if (declaration.type == "Declaration") {
+					if (declaration.type == "Declaration" && declaration.value.children) {
 						const urlFunctions = DomUtil.getUrlFunctions(DomUtil.getCSSValue(declaration.value));
 						await Promise.all(urlFunctions.map(async urlFunction => {
 							const originalResourceURL = DomUtil.matchURL(urlFunction);
@@ -1244,15 +1244,11 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 									if (!validResource) {
 										content = EMPTY_DATA_URI;
 									}
-									if (declaration.value.children) {
-										declaration.value.children.forEach(token => {
-											if (token.type == "Url" && DOM.removeQuotes(DomUtil.getCSSValue(token.value)) == originalResourceURL) {
-												token.value.value = content;
-											}
-										});
-									} else {
-										declaration.value = "url(" + content + ")";
-									}
+									declaration.value.children.forEach(token => {
+										if (token.type == "Url" && DOM.removeQuotes(DomUtil.getCSSValue(token.value)) == originalResourceURL) {
+											token.value.value = content;
+										}
+									});
 								}
 							}
 						}));