mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(Page.waitForSelector): "visible" option should check parent visibility (#1354)
This patch starts checking for boundingClientRect to make sure that the element is visible.
This commit is contained in:
committed by
Andrey Lushnikov
parent
44d1e834a4
commit
f8d19e79e7
@@ -502,8 +502,16 @@ class Frame {
|
||||
if (!waitForVisible && !waitForHidden)
|
||||
return true;
|
||||
const style = window.getComputedStyle(node);
|
||||
const isVisible = style && style.display !== 'none' && style.visibility !== 'hidden';
|
||||
const isVisible = style && style.visibility !== 'hidden' && hasVisibleBoundingBox();
|
||||
return (waitForVisible === isVisible || waitForHidden === !isVisible);
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
function hasVisibleBoundingBox() {
|
||||
const rect = node.getBoundingClientRect();
|
||||
return !!(rect.top || rect.bottom || rect.width || rect.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user