|
|
@@ -107,9 +107,6 @@ this.docHelper = this.docHelper || (() => {
|
|
|
if (options.removeHiddenElements || options.removeUnusedFonts || options.compressHTML) {
|
|
|
const computedStyle = win.getComputedStyle(element);
|
|
|
if (options.removeHiddenElements) {
|
|
|
- const display = computedStyle.getPropertyValue("display");
|
|
|
- const opacity = computedStyle.getPropertyValue("opacity");
|
|
|
- const visibility = computedStyle.getPropertyValue("visibility");
|
|
|
if (ascendantHidden) {
|
|
|
Array.from(element.childNodes).filter(node => node instanceof win.HTMLElement).forEach(element => {
|
|
|
if (!options.ignoredTags.includes(element.tagName)) {
|
|
|
@@ -117,7 +114,7 @@ this.docHelper = this.docHelper || (() => {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- elementHidden = ascendantHidden || testHiddenElement(element, { display, opacity, visibility });
|
|
|
+ elementHidden = ascendantHidden || testHiddenElement(element, computedStyle);
|
|
|
}
|
|
|
if (options.compressHTML) {
|
|
|
const whiteSpace = computedStyle.getPropertyValue("white-space");
|
|
|
@@ -219,11 +216,14 @@ this.docHelper = this.docHelper || (() => {
|
|
|
return removeQuotes(fontFamilyName.trim()).toLowerCase();
|
|
|
}
|
|
|
|
|
|
- function testHiddenElement(element, style) {
|
|
|
+ function testHiddenElement(element, computedStyle) {
|
|
|
let hidden = false;
|
|
|
- if (style) {
|
|
|
- hidden = style.display == "none";
|
|
|
- if (!hidden && (style.opacity == "0" || style.visibility == "hidden") && element.getBoundingClientRect) {
|
|
|
+ if (computedStyle) {
|
|
|
+ const display = computedStyle.getPropertyValue("display");
|
|
|
+ const opacity = computedStyle.getPropertyValue("opacity");
|
|
|
+ const visibility = computedStyle.getPropertyValue("visibility");
|
|
|
+ hidden = display == "none";
|
|
|
+ if (!hidden && (opacity == "0" || visibility == "hidden") && element.getBoundingClientRect) {
|
|
|
const boundingRect = element.getBoundingClientRect();
|
|
|
hidden = !boundingRect.width && !boundingRect.height;
|
|
|
}
|