Skip to content

Commit

Permalink
All cells should have a content wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki committed Dec 3, 2016
1 parent b51468c commit 9edf377
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
40 changes: 18 additions & 22 deletions test/column-groups.html
Expand Up @@ -139,11 +139,11 @@
var grid, scroller, header, body, footer, headerRows, footerRows;

function getFooterCellContent(row, col) {
return getFooterCell(row, col).textContent.trim();
return getCellContent(getFooterCell(row, col)).textContent.trim();
}

function getHeaderCellContent(row, col) {
return getHeaderCell(row, col).textContent.trim();
return getCellContent(getHeaderCell(row, col)).textContent.trim();
}

function getHeaderCell(row, col) {
Expand Down Expand Up @@ -179,32 +179,34 @@
var cells = Polymer.dom(header).querySelectorAll('th');
expect(cells).not.to.be.empty;

cells.forEach(function(el) {
cells.forEach(function(cell) {
var el = getCellContent(cell);
expect(el.matches(':empty')).to.be.true;
});
});

it('should not have a border below the header', function() {
var cells = Polymer.dom(header).querySelectorAll('th');
var cellOnLastRow = cells[cells.length - 1];

expect(window.getComputedStyle(cellOnLastRow).borderBottomStyle).to.eql('none');
var el = getCellContent(cellOnLastRow);
expect(window.getComputedStyle(el).borderBottomStyle).to.eql('none');
});

it('should have empty footer', function() {
var cells = Polymer.dom(footer).querySelectorAll('td');
expect(cells).not.to.be.empty;

cells.forEach(function(el) {
cells.forEach(function(cell) {
var el = getCellContent(cell);
expect(el.matches(':empty')).to.be.true;
});
});

it('should not have a border above the footer', function() {
var cells = Polymer.dom(footer).querySelectorAll('td');
var cellOnFirstRow = cells[0];

expect(window.getComputedStyle(cellOnFirstRow).borderTopStyle).to.eql('none');
var el = getCellContent(cellOnFirstRow);
expect(window.getComputedStyle(el).borderTopStyle).to.eql('none');
});
});

Expand Down Expand Up @@ -319,23 +321,17 @@
expect(getFooterCellContent(2, 1)).to.equal('group-1');
});

it('should contain empty cells in headers', function() {
[
[0, 2],
[1, 0], [1, 1], [1, 4],
[2, 0], [2, 1], [2, 2], [2, 3]
].forEach(function(a) {
expect(getHeaderCell(a[0], a[1]).matches(':empty')).to.be.true;
it('should have cell content wrappers in all header cells', function() {
Polymer.dom(header).querySelectorAll('th').forEach(function(a) {
var content = getCellContent(a);
expect(content.matches('.cell-content')).to.be.true;
});
});

it('should contain empty cells in footers but reversed', function() {
[
[2, 2],
[1, 0], [1, 1], [1, 4],
[0, 0], [0, 1], [0, 2], [0, 3]
].forEach(function(a) {
expect(getFooterCell(a[0], a[1]).matches(':empty')).to.be.true;
it('should have cell content wrappers in all footer cells', function() {
Polymer.dom(footer).querySelectorAll('td').forEach(function(a) {
var content = getCellContent(a);
expect(content.matches('.cell-content')).to.be.true;
});
});

Expand Down
4 changes: 2 additions & 2 deletions vaadin-grid-column.html
Expand Up @@ -17,13 +17,13 @@
headerTemplate: {
type: Object,
value: function() {
return this._findTemplate('template.header');
return this._findTemplate('template.header') || null;
}
},
footerTemplate: {
type: Object,
value: function() {
return this._findTemplate('template.footer');
return this._findTemplate('template.footer') || null;
}
},
instances: {
Expand Down
12 changes: 8 additions & 4 deletions vaadin-grid-table-cell.html
Expand Up @@ -132,7 +132,7 @@
Polymer.dom(this.target).removeChild(cellContent);
}
}
},
},

_widthChanged: function(width) {
this.style.flexBasis = width;
Expand Down Expand Up @@ -176,7 +176,7 @@
this._cellContent.setAttribute('data-cell-content-id', target._contentIndex);

var content = document.createElement('content');
content.setAttribute('select', '[data-cell-content-id="' + target._contentIndex +'"]');
content.setAttribute('select', '[data-cell-content-id="' + target._contentIndex + '"]');
Polymer.dom(this).appendChild(content);
} else {
// Non-shadow
Expand Down Expand Up @@ -295,8 +295,10 @@
observers: ['_headerTemplateChanged(headerTemplate, target)'],

_headerTemplateChanged: function(headerTemplate, target) {
if (this._isColumnRow || this.column.localName === 'vaadin-grid-column-group') {
if (headerTemplate !== null && (this._isColumnRow || this.column.localName === 'vaadin-grid-column-group')) {
this._templateChanged(headerTemplate, target);
} else {
this._templateChanged(document.createElement('template'), target);
}
}
});
Expand All @@ -318,8 +320,10 @@
observers: ['_footerTemplateChanged(footerTemplate, target)'],

_footerTemplateChanged: function(footerTemplate, target) {
if (this._isColumnRow || this.column.localName === 'vaadin-grid-column-group') {
if (footerTemplate !== null && (this._isColumnRow || this.column.localName === 'vaadin-grid-column-group')) {
this._templateChanged(footerTemplate, target);
} else {
this._templateChanged(document.createElement('template'), target);
}
}
});
Expand Down

0 comments on commit 9edf377

Please sign in to comment.