|
|
@@ -66,11 +66,11 @@ this.rulesMinifier = this.rulesMinifier || (() => {
|
|
|
let stylesheetContent = "";
|
|
|
if (rules) {
|
|
|
Array.from(rules).forEach(rule => {
|
|
|
- if (rule.media) {
|
|
|
+ if (rule.type == CSSRule.MEDIA_RULE) {
|
|
|
stylesheetContent += "@media " + Array.prototype.join.call(rule.media, ",") + " {";
|
|
|
stylesheetContent += processRules(doc, rule.cssRules, rulesData);
|
|
|
stylesheetContent += "}";
|
|
|
- } else if (rule.selectorText) {
|
|
|
+ } else if (rule.type == CSSRule.STYLE_RULE) {
|
|
|
const selector = getFilteredSelector(rule.selectorText);
|
|
|
if (selector) {
|
|
|
try {
|
|
|
@@ -79,6 +79,7 @@ this.rulesMinifier = this.rulesMinifier || (() => {
|
|
|
rulesData.selectors.add(selector);
|
|
|
if (rule.style && rule.style.fontFamily) {
|
|
|
rule.style.fontFamily.split(",").forEach(fontFamily => rulesData.fonts.used.add(getFontFamily(fontFamily)));
|
|
|
+ rule.style.fontFamily.split(",").forEach(fontFamily => console.log("used", getFontFamily(fontFamily)));
|
|
|
}
|
|
|
}
|
|
|
} catch (error) {
|
|
|
@@ -86,8 +87,10 @@ this.rulesMinifier = this.rulesMinifier || (() => {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- if (rule.type == CSSRule.FONT_FACE_RULE && rule.style && rule.style.fontFamily) {
|
|
|
- rulesData.fonts.declared.add(getFontFamily(rule.style.fontFamily));
|
|
|
+ const fontFamily = rule.style && rule.style.getPropertyValue("font-family");
|
|
|
+ if (rule.type == CSSRule.FONT_FACE_RULE && rule.style && fontFamily) {
|
|
|
+ rulesData.fonts.declared.add(getFontFamily(fontFamily));
|
|
|
+ console.log("declared", getFontFamily(fontFamily));
|
|
|
}
|
|
|
stylesheetContent += rule.cssText;
|
|
|
}
|
|
|
@@ -100,11 +103,12 @@ this.rulesMinifier = this.rulesMinifier || (() => {
|
|
|
let stylesheetContent = "";
|
|
|
if (rules) {
|
|
|
Array.from(rules).forEach(rule => {
|
|
|
+ const fontFamily = rule.style && rule.style.getPropertyValue("font-family");
|
|
|
if (rule.media) {
|
|
|
stylesheetContent += "@media " + Array.prototype.join.call(rule.media, ",") + " {";
|
|
|
stylesheetContent += deleteUnusedFonts(doc, rule.cssRules, unusedFonts);
|
|
|
stylesheetContent += "}";
|
|
|
- } else if (rule.type != CSSRule.FONT_FACE_RULE || (rule.type == CSSRule.FONT_FACE_RULE && rule.style && rule.style.fontFamily && !unusedFonts.includes(getFontFamily(rule.style.fontFamily)))) {
|
|
|
+ } else if (rule.type != CSSRule.FONT_FACE_RULE || (rule.type == CSSRule.FONT_FACE_RULE && rule.style && fontFamily && !unusedFonts.includes(getFontFamily(fontFamily)))) {
|
|
|
stylesheetContent += rule.cssText;
|
|
|
}
|
|
|
});
|