Skip to content

Commit 6ee07f0

Browse files
committed
Check for visibility:collapse
Fixes #530
1 parent 2f6f868 commit 6ee07f0

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

Diff for: javascript/atoms/dom.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,9 @@ bot.dom.isShown = function(elem, opt_ignoreOpacity) {
596596
return false;
597597
}
598598

599-
// Any element with hidden visibility is not shown.
600-
if (bot.dom.getEffectiveStyle(elem, 'visibility') == 'hidden') {
599+
// Any element with hidden/collapsed visibility is not shown.
600+
var visibility = bot.dom.getEffectiveStyle(elem, 'visibility');
601+
if (visibility == 'collapse' || visibility == 'hidden') {
601602
return false;
602603
}
603604

Diff for: javascript/atoms/test/shown_test.html

+28
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,29 @@
357357
assertFalse(isShown(elem));
358358
});
359359
}
360+
361+
function testTableRowDefaultVisibility() {
362+
var elem = findElement({id: 'visible-row'});
363+
assertTrue(isShown(elem));
364+
assertTrue(isShown(elem.firstChild));
365+
}
366+
367+
function testTableRowCollapsedVisibility() {
368+
expectedFailures.expectFailureFor(
369+
(goog.userAgent.IE && !goog.userAgent.isDocumentModeOrHigher(8)),
370+
'IE does not support visibilty:collapsed until IE8');
371+
var elem = findElement({id: 'collapsed-row'});
372+
expectedFailures.run(function() {
373+
assertFalse(isShown(elem));
374+
assertFalse(isShown(elem.firstChild));
375+
});
376+
}
377+
378+
function testVisibleTableRowAfterCollapsedRow() {
379+
var elem = findElement({id: 'post-collapsed-row'});
380+
assertTrue(isShown(elem));
381+
assertTrue(isShown(elem.firstChild));
382+
}
360383
</script>
361384

362385
<style type="text/css">
@@ -532,5 +555,10 @@
532555
</div>
533556
</div>
534557
<div id='html5hidden' hidden>This is not visible</div>
558+
<table>
559+
<tr id="visible-row"><td>a</td></tr>
560+
<tr id="collapsed-row" style="visibility:collapse"><td>b</td></tr>
561+
<tr id="post-collapsed-row"><td>c</td></tr>
562+
</table>
535563
</body>
536564
</html>

Diff for: javascript/atoms/test/text_table_test.html

+27
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
goog.require('bot.userAgent');
2626
goog.require('goog.array');
2727
goog.require('goog.dom');
28+
goog.require('goog.testing.ExpectedFailures');
2829
goog.require('goog.testing.jsunit');
2930
</script>
3031
<style>
@@ -47,6 +48,15 @@
4748
var TD = goog.partial(goog.dom.createDom, goog.dom.TagName.TD, null);
4849
var P = goog.partial(goog.dom.createDom, goog.dom.TagName.P, null);
4950

51+
var expectedFailures;
52+
53+
function setUp() {
54+
expectedFailures = new goog.testing.ExpectedFailures();
55+
}
56+
57+
function tearDown() {
58+
expectedFailures.handleTearDown();
59+
}
5060

5161
function testEmptyTable() {
5262
assertTextIs(TABLE(), '');
@@ -196,7 +206,24 @@
196206
"Table 2, Row 1, Cell 1 Table 2, Row 1, Cell 2",
197207
"Table 1, Row 3, Cell 1 Table 1, Row 3, Cell 2");
198208
}
209+
210+
211+
function testTableWithCollapsedRows() {
212+
expectedFailures.expectFailureFor(
213+
(goog.userAgent.IE && !goog.userAgent.isDocumentModeOrHigher(8)),
214+
'IE does not support visibilty:collapsed until IE8');
215+
expectedFailures.run(function() {
216+
assertTextIs(
217+
goog.dom.getElement('collapsedTable'),
218+
'a', 'c');
219+
});
220+
}
199221
</script>
222+
<table id="collapsedTable">
223+
<tr><td>a</td></tr>
224+
<tr style="visibility:collapse"><td>b</td></tr>
225+
<tr><td>c</td></tr>
226+
</table>
200227
<table id="nestedTable">
201228
<tr>
202229
<td>

0 commit comments

Comments
 (0)