Skip to content

Commit 4c889b9

Browse files
committed
js atoms: Ensure element with overflow state 'hidden' is considered hidden if
all its children have zero size. On behalf of Google engineers.
1 parent c8b388a commit 4c889b9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

javascript/atoms/dom.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,8 @@ bot.dom.isShown = function(elem, opt_ignoreOpacity) {
663663
function hiddenByOverflow(e) {
664664
return bot.dom.getOverflowState(e) == bot.dom.OverflowState.HIDDEN &&
665665
goog.array.every(e.childNodes, function(n) {
666-
return !bot.dom.isElement(n) || hiddenByOverflow(n);
666+
return !bot.dom.isElement(n) || hiddenByOverflow(n) ||
667+
!positiveSize(n);
667668
});
668669
}
669670
return !hiddenByOverflow(elem);

javascript/atoms/test/shown_test.html

+16
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,15 @@
338338
assertFalse(isShown(target));
339339
}
340340

341+
function testOverflowHiddenWithFixedPositionChild() {
342+
var target = findElement({id: 'overflowHiddenWithFixedPositionChild'});
343+
var child = findElement({id: 'fixedPositionChild'});
344+
child.innerHTML = '';
345+
assertFalse(isShown(target));
346+
child.innerHTML = 'some content';
347+
assertTrue(isShown(target));
348+
}
349+
341350
function testThatElementIsShownWithZIndex() {
342351
assertTrue(isShown(findElement({id: 'bug5109'})));
343352
}
@@ -532,6 +541,13 @@
532541
This is a zero height/width div and overflow hidden
533542
</div>
534543

544+
<div style="overflow:hidden; height:0; width:0;">
545+
<div id="overflowHiddenWithFixedPositionChild">
546+
This is a zero height/width div and overflow hidden
547+
<div id="fixedPositionChild" style="position:fixed"></div>
548+
</div>
549+
</div>
550+
535551
<div style="position:relative;
536552
width:300px;
537553
height:300px;

0 commit comments

Comments
 (0)