@@ -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.
@@ -506,7 +506,7 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
506
506
return false ;
507
507
}
508
508
509
- if ( ! parentsDisplayedFn ( elem ) ) {
509
+ if ( ! displayedFn ( elem ) ) {
510
510
return false ;
511
511
}
512
512
@@ -527,6 +527,16 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
527
527
var strokeWidth = bot . dom . getEffectiveStyle ( e , 'stroke-width' ) ;
528
528
return ! ! strokeWidth && ( parseInt ( strokeWidth , 10 ) > 0 ) ;
529
529
}
530
+
531
+ // Any element with hidden/collapsed visibility is not shown.
532
+ var visibility = bot . dom . getEffectiveStyle ( e , 'visibility' ) ;
533
+ if ( visibility == 'collapse' || visibility == 'hidden' ) {
534
+ return false ;
535
+ }
536
+
537
+ if ( ! displayedFn ( e ) ) {
538
+ return false ;
539
+ }
530
540
// Zero-sized elements should still be considered to have positive size
531
541
// if they have a child element or text node with positive size, unless
532
542
// the element has an 'overflow' style of 'hidden'.
@@ -572,7 +582,7 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
572
582
*/
573
583
bot . dom . isShown = function ( elem , opt_ignoreOpacity ) {
574
584
/**
575
- * Determines whether an element or its parents have `display: none` set
585
+ * Determines whether an element or its parents have `display: none` or similar CSS properties set
576
586
* @param {!Node } e the element
577
587
* @return {!boolean }
578
588
*/
0 commit comments