@@ -452,12 +452,12 @@ bot.dom.getCascadedStyle_ = function (elem, styleName) {
452
452
* @param {!Element } elem The element to consider.
453
453
* @param {boolean } ignoreOpacity Whether to ignore the element's opacity
454
454
* when determining whether it is shown.
455
- * @param {function(!Element):boolean } parentsDisplayedFn a function that's used
456
- * to tell if the chain of ancestors are all shown.
455
+ * @param {function(!Element):boolean } displayedFn a function that's used
456
+ * to tell if the chain of ancestors or descendants are all shown.
457
457
* @return {boolean } Whether or not the element is visible.
458
458
* @private
459
459
*/
460
- bot . dom . isShown_ = function ( elem , ignoreOpacity , parentsDisplayedFn ) {
460
+ bot . dom . isShown_ = function ( elem , ignoreOpacity , displayedFn ) {
461
461
if ( ! bot . dom . isElement ( elem ) ) {
462
462
throw new Error ( 'Argument to isShown must be of type Element' ) ;
463
463
}
@@ -476,7 +476,7 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
476
476
var select = /**@type {Element }*/ ( goog . dom . getAncestor ( elem , function ( e ) {
477
477
return bot . dom . isElement ( e , goog . dom . TagName . SELECT ) ;
478
478
} ) ) ;
479
- return ! ! select && bot . dom . isShown_ ( select , true , parentsDisplayedFn ) ;
479
+ return ! ! select && bot . dom . isShown_ ( select , true , displayedFn ) ;
480
480
}
481
481
482
482
// Image map elements are shown if image that uses it is shown, and
@@ -486,7 +486,7 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
486
486
return ! ! imageMap . image &&
487
487
imageMap . rect . width > 0 && imageMap . rect . height > 0 &&
488
488
bot . dom . isShown_ (
489
- imageMap . image , ignoreOpacity , parentsDisplayedFn ) ;
489
+ imageMap . image , ignoreOpacity , displayedFn ) ;
490
490
}
491
491
492
492
// Any hidden input is not shown.
@@ -500,13 +500,7 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
500
500
return false ;
501
501
}
502
502
503
- // Any element with hidden/collapsed visibility is not shown.
504
- var visibility = bot . dom . getEffectiveStyle ( elem , 'visibility' ) ;
505
- if ( visibility == 'collapse' || visibility == 'hidden' ) {
506
- return false ;
507
- }
508
-
509
- if ( ! parentsDisplayedFn ( elem ) ) {
503
+ if ( ! displayedFn ( elem ) ) {
510
504
return false ;
511
505
}
512
506
@@ -527,6 +521,9 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
527
521
var strokeWidth = bot . dom . getEffectiveStyle ( e , 'stroke-width' ) ;
528
522
return ! ! strokeWidth && ( parseInt ( strokeWidth , 10 ) > 0 ) ;
529
523
}
524
+ if ( ! displayedFn ( e ) ) {
525
+ return false ;
526
+ }
530
527
// Zero-sized elements should still be considered to have positive size
531
528
// if they have a child element or text node with positive size, unless
532
529
// the element has an 'overflow' style of 'hidden'.
@@ -572,14 +569,17 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
572
569
*/
573
570
bot . dom . isShown = function ( elem , opt_ignoreOpacity ) {
574
571
/**
575
- * Determines whether an element or its parents have `display: none` set
572
+ * Determines whether an element or its parents have `display: none` or similar CSS properties set
576
573
* @param {!Node } e the element
577
574
* @return {!boolean }
578
575
*/
579
576
function displayed ( e ) {
580
577
if ( bot . dom . isElement ( e ) ) {
581
578
var elem = /** @type {!Element } */ ( e ) ;
582
579
if ( ( bot . dom . getEffectiveStyle ( elem , 'display' ) == 'none' )
580
+ // Any element with hidden/collapsed visibility is not shown.
581
+ || ( bot . dom . getEffectiveStyle ( elem , 'visibility' ) == 'hidden' )
582
+ || ( bot . dom . getEffectiveStyle ( elem , 'visibility' ) == 'collapse' )
583
583
|| ( bot . dom . getEffectiveStyle ( elem , 'content-visibility' ) == 'hidden' ) ) {
584
584
return false ;
585
585
}
0 commit comments