Skip to content

Commit a0ffd36

Browse files
authored
fix: check if grid column is attached (#2159)
Fixes: #1981 Warranty: Prevent an exception when changing the size after removing columns Cherrypick: vaadin/web-components#195
1 parent ac1b707 commit a0ffd36

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/vaadin-grid.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,9 @@
508508
}
509509

510510
if (this._columnTree) {
511-
this._columnTree[this._columnTree.length - 1].forEach(c => c.notifyPath && c.notifyPath('_cells.*', c._cells));
511+
this._columnTree[this._columnTree.length - 1].forEach(
512+
(c) => c.isConnected && c.notifyPath && c.notifyPath('_cells.*', c._cells)
513+
);
512514
}
513515

514516
Polymer.RenderStatus.beforeNextRender(this, () => {

test/column.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,15 @@
587587
expect(column._bodyTemplate).to.eql(template2);
588588
});
589589
});
590+
591+
it('should not throw an exception when size is changed after removing column', () => {
592+
expect(grid.size).to.equal(10);
593+
expect(column.isConnected).to.be.true;
594+
column.parentNode.removeChild(column);
595+
expect(column.isConnected).to.be.false;
596+
expect(() => (grid.size = 11)).not.to.throw();
597+
expect(grid.size).to.equal(11);
598+
});
590599
});
591600

592601
describe('pro host', () => {

0 commit comments

Comments
 (0)