|
|
@@ -47,7 +47,7 @@ this.docHelper = this.docHelper || (() => {
|
|
|
if (options.removeHiddenElements) {
|
|
|
doc.querySelectorAll("html > body *:not(style):not(script):not(link):not(frame):not(iframe):not(object)").forEach(element => {
|
|
|
const style = win.getComputedStyle(element);
|
|
|
- if (element instanceof win.HTMLElement && (element.hidden || style.display == "none" || ((style.opacity === 0 || style.visibility == "hidden") && !element.clientWidth && !element.clientHeight)) && !element.querySelector("iframe, frame, object[type=\"text/html\"][data]")) {
|
|
|
+ if (element instanceof win.HTMLElement && style && (element.hidden || style.display == "none" || ((style.opacity === 0 || style.visibility == "hidden") && !element.clientWidth && !element.clientHeight)) && !element.querySelector("iframe, frame, object[type=\"text/html\"][data]")) {
|
|
|
element.setAttribute(REMOVED_CONTENT_ATTRIBUTE_NAME, "");
|
|
|
}
|
|
|
});
|
|
|
@@ -55,7 +55,7 @@ this.docHelper = this.docHelper || (() => {
|
|
|
if (options.compressHTML) {
|
|
|
doc.querySelectorAll("*").forEach(element => {
|
|
|
const style = win.getComputedStyle(element);
|
|
|
- if (style.whiteSpace.startsWith("pre")) {
|
|
|
+ if (style && style.whiteSpace.startsWith("pre")) {
|
|
|
element.setAttribute(PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME, "");
|
|
|
}
|
|
|
});
|