fix: remove boundary conditions for visibility (#9249)

Fixed: https://github.com/puppeteer/puppeteer/issues/9232
This commit is contained in:
jrandolf 2022-11-14 09:34:07 +01:00 committed by GitHub
parent 86abe68849
commit e003513c0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,11 +58,11 @@ export const checkVisibility = (
const isVisible = const isVisible =
style && style &&
!HIDDEN_VISIBILITY_VALUES.includes(style.visibility) && !HIDDEN_VISIBILITY_VALUES.includes(style.visibility) &&
isBoundingBoxVisible(element); !isBoundingBoxEmpty(element);
return visible === isVisible ? node : false; return visible === isVisible ? node : false;
}; };
function isBoundingBoxVisible(element: Element): boolean { function isBoundingBoxEmpty(element: Element): boolean {
const rect = element.getBoundingClientRect(); const rect = element.getBoundingClientRect();
return rect.width > 0 && rect.height > 0 && rect.right > 0 && rect.bottom > 0; return rect.width === 0 || rect.height === 0;
} }