@@ -452,12 +452,12 @@ bot.dom.getCascadedStyle_ = function (elem, styleName) {
452452 * @param {!Element } elem The element to consider.
453453 * @param {boolean } ignoreOpacity Whether to ignore the element's opacity
454454 * 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.
457457 * @return {boolean } Whether or not the element is visible.
458458 * @private
459459 */
460- bot . dom . isShown_ = function ( elem , ignoreOpacity , parentsDisplayedFn ) {
460+ bot . dom . isShown_ = function ( elem , ignoreOpacity , displayedFn ) {
461461 if ( ! bot . dom . isElement ( elem ) ) {
462462 throw new Error ( 'Argument to isShown must be of type Element' ) ;
463463 }
@@ -476,7 +476,7 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
476476 var select = /**@type {Element }*/ ( goog . dom . getAncestor ( elem , function ( e ) {
477477 return bot . dom . isElement ( e , goog . dom . TagName . SELECT ) ;
478478 } ) ) ;
479- return ! ! select && bot . dom . isShown_ ( select , true , parentsDisplayedFn ) ;
479+ return ! ! select && bot . dom . isShown_ ( select , true , displayedFn ) ;
480480 }
481481
482482 // Image map elements are shown if image that uses it is shown, and
@@ -486,7 +486,7 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
486486 return ! ! imageMap . image &&
487487 imageMap . rect . width > 0 && imageMap . rect . height > 0 &&
488488 bot . dom . isShown_ (
489- imageMap . image , ignoreOpacity , parentsDisplayedFn ) ;
489+ imageMap . image , ignoreOpacity , displayedFn ) ;
490490 }
491491
492492 // Any hidden input is not shown.
@@ -506,7 +506,7 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
506506 return false ;
507507 }
508508
509- if ( ! parentsDisplayedFn ( elem ) ) {
509+ if ( ! displayedFn ( elem ) ) {
510510 return false ;
511511 }
512512
@@ -527,6 +527,16 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
527527 var strokeWidth = bot . dom . getEffectiveStyle ( e , 'stroke-width' ) ;
528528 return ! ! strokeWidth && ( parseInt ( strokeWidth , 10 ) > 0 ) ;
529529 }
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+ }
530540 // Zero-sized elements should still be considered to have positive size
531541 // if they have a child element or text node with positive size, unless
532542 // the element has an 'overflow' style of 'hidden'.
@@ -572,7 +582,7 @@ bot.dom.isShown_ = function (elem, ignoreOpacity, parentsDisplayedFn) {
572582 */
573583bot . dom . isShown = function ( elem , opt_ignoreOpacity ) {
574584 /**
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
576586 * @param {!Node } e the element
577587 * @return {!boolean }
578588 */
0 commit comments