Skip to content

Commit 1374b33

Browse files
twalpolebarancev
authored andcommitted
Fix visibility checking for descendants of details elements
Signed-off-by: Alexei Barantsev <[email protected]>
1 parent 06a7dff commit 1374b33

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

javascript/atoms/dom.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -469,14 +469,6 @@ bot.dom.isShown_ = function(elem, ignoreOpacity, parentsDisplayedFn) {
469469
return true;
470470
}
471471

472-
// Child of DETAILS element is not shown unless the DETAILS element is open
473-
// or the child is a SUMMARY element.
474-
var parent = bot.dom.getParentElement(elem);
475-
if (parent && bot.dom.isElement(parent, goog.dom.TagName.DETAILS) &&
476-
!parent.open && !bot.dom.isElement(elem, goog.dom.TagName.SUMMARY)) {
477-
return false;
478-
}
479-
480472
// Option or optgroup is shown iff enclosing select is shown (ignoring the
481473
// select's opacity).
482474
if (bot.dom.isElement(elem, goog.dom.TagName.OPTION) ||
@@ -610,6 +602,13 @@ bot.dom.isShown = function(elem, opt_ignoreOpacity) {
610602
return true;
611603
}
612604

605+
// Child of DETAILS element is not shown unless the DETAILS element is open
606+
// or the child is a SUMMARY element.
607+
if (parent && bot.dom.isElement(parent, goog.dom.TagName.DETAILS) &&
608+
!parent.open && !bot.dom.isElement(e, goog.dom.TagName.SUMMARY)) {
609+
return false;
610+
}
611+
613612
return parent && displayed(parent);
614613
}
615614

javascript/atoms/test/shown_test.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,17 @@
393393
function testDisplayContentsOverflowIgnored() {
394394
assertTrue(isShown(findElement({id: 'displayContentsInput'})));
395395
}
396+
397+
function testDetailsSummaryVisibility() {
398+
var summary = findElement({id: 'summary'});
399+
assertTrue(isShown(summary));
400+
}
401+
402+
function testDetailsNonSummaryDescendantsVisibility() {
403+
var contents = findElement({id: 'non-summary'});
404+
assertFalse(isShown(contents));
405+
assertFalse(isShown(contents.firstChild));
406+
}
396407
</script>
397408

398409
<style type="text/css">
@@ -585,5 +596,11 @@
585596
<tr id="collapsed-row" style="visibility:collapse"><td>b</td></tr>
586597
<tr id="post-collapsed-row"><td>c</td></tr>
587598
</table>
599+
600+
<details>
601+
<summary id="summary">Some Summary</summary>
602+
<div id="non-summary"><p>More text</p></div>
603+
</details>
604+
588605
</body>
589606
</html>

0 commit comments

Comments
 (0)