Skip to content

Commit

Permalink
BODY element is always shown/displayed.
Browse files Browse the repository at this point in the history
  • Loading branch information
sevaseva committed Jun 25, 2014
1 parent 9292f01 commit 039b6a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions javascript/atoms/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,12 @@ bot.dom.isShown = function(elem, opt_ignoreOpacity) {
throw new Error('Argument to isShown must be of type Element');
}

// By convention, BODY element is always shown: BODY represents the document
// and even if there's nothing rendered in there, user can always see there's the document.
if (bot.dom.isElement(elem, goog.dom.TagName.BODY)) {
return true;
}

// Option or optgroup is shown iff enclosing select is shown (ignoring the
// select's opacity).
if (bot.dom.isElement(elem, goog.dom.TagName.OPTION) ||
Expand Down
11 changes: 10 additions & 1 deletion javascript/atoms/test/shown_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
expectedFailures = new goog.testing.ExpectedFailures();
}


function tearDown() {
expectedFailures.handleTearDown();
goog.style.setStyle(document.body, 'display', 'block');
goog.style.setStyle(document.body, 'overflow', 'auto');
}

Expand All @@ -52,6 +52,15 @@
});
}

function testBodyShown() {
assertTrue(isShown(document.body));
}

function testBodyAlwaysShown() {
goog.style.setStyle(document.body, 'display', 'none');
assertTrue("BODY element must *always* be shown", isShown(document.body));
}

function testCanDetermineIfAnElementIsShownOrNot() {
assertTrue(isShown(findElement({id: 'displayed'})));
assertFalse(isShown(findElement({id: 'none'})));
Expand Down

0 comments on commit 039b6a4

Please sign in to comment.