Skip to content

Commit 31b65bb

Browse files
committed
fix(style): Do not require thead/tbody
Iterate over all <tr> in order to setup data-title attribute. Fixes #2
1 parent 4b96c28 commit 31b65bb

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

release/angular-responsive-tables.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818

1919
/* Hide table headers (but not display: none;, for accessibility) */
20-
.responsive thead tr {
20+
.responsive thead tr, .responsive th {
2121
position: absolute;
2222
top: -9999px;
2323
left: -9999px;

release/angular-responsive-tables.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818

1919
/* Hide table headers (but not display: none;, for accessibility) */
20-
.responsive thead tr {
20+
.responsive thead tr, .responsive th {
2121
position: absolute;
2222
top: -9999px;
2323
left: -9999px;

tests/directive.spec.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,41 @@ describe('directive', function () {
1111
$rootScope = _$rootScope_;
1212
}));
1313

14+
it('supports rows with no <thead>', function () {
15+
var markup = [
16+
'<table wt-responsive-table>',
17+
' <tr>',
18+
' <th>First title</th>',
19+
' <th>Second title</th>',
20+
' <th>Third title</th>',
21+
' <th>Forth title</th>',
22+
' </tr>',
23+
' <tr>',
24+
' <td>First column</td>',
25+
' <td>Second column</td>',
26+
' <td>Third column</td>',
27+
' <td>Forth column</td>',
28+
' </tr>',
29+
'</table>'
30+
].join('');
31+
var element = angular.element(markup);
32+
document.body.appendChild(element[0]);
33+
$compile(element);
34+
35+
var firstDataRow = element.find('tr td');
36+
expect(firstDataRow.eq(0).attr('data-title')).toBe('First title');
37+
expect(firstDataRow.eq(1).attr('data-title')).toBe('Second title');
38+
expect(firstDataRow.eq(2).attr('data-title')).toBe('Third title');
39+
expect(firstDataRow.eq(3).attr('data-title')).toBe('Forth title');
40+
41+
var headerRow = element.find('tr th');
42+
expect(headerRow.eq(0).attr('data-title')).toBeUndefined();
43+
expect(headerRow.eq(1).attr('data-title')).toBeUndefined();
44+
expect(headerRow.eq(2).attr('data-title')).toBeUndefined();
45+
expect(headerRow.eq(3).attr('data-title')).toBeUndefined();
46+
expect(headerRow.is(':visible')).toBe(true);
47+
});
48+
1449
it('supports colspan', function () {
1550
var markup = [
1651
'<table wt-responsive-table>',

0 commit comments

Comments
 (0)