Skip to content

Commit

Permalink
No light DOM operations needed on row reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki committed Dec 8, 2016
1 parent f43ecf2 commit e01d53a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
18 changes: 18 additions & 0 deletions test/basic.html
Expand Up @@ -195,6 +195,24 @@
});
});

if (Polymer.Settings.useShadow) {
test('reorder should not affect light dom', function() {
list.size = 100000;
var wrappers = Polymer.dom(container).querySelectorAll('.cell-content');

[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144].forEach(function(steps) {
list.$.table.scrollTop = 5000 + list._physicalAverage * steps;
list._scrollHandler();
list.flushDebouncer('_debounceTemplate');
list.flushDebouncer('reorderrows');

var newWrappers = Polymer.dom(container).querySelectorAll('.cell-content');
// Expect the light dom order unchanged
expect(newWrappers).to.eql(wrappers);
});
});
}

});
</script>

Expand Down
12 changes: 12 additions & 0 deletions test/row-details.html
Expand Up @@ -131,6 +131,18 @@
expect(grid.$.scroller._frozenCells).to.be.empty;
});

if (Polymer.Settings.useShadow) {
it('should remove unused nodes from the light DOM', function(done) {
expandRow(1);
var childCount = grid.children.length;
collapseRow(1);
Polymer.Base.async(function() {
expect(grid.children.length).to.equal(childCount - 1);
done();
}, 1);
});
}

});
</script>

Expand Down
12 changes: 9 additions & 3 deletions vaadin-grid-table-cell.html
Expand Up @@ -147,9 +147,15 @@
_toggleContent: function(isAttached, cellContent) {
if (Polymer.Settings.useShadow) {
if (isAttached) {
Polymer.dom(this.target).appendChild(cellContent);
} else if (cellContent.parentNode) {
Polymer.dom(this.target).removeChild(cellContent);
if (!cellContent.parentNode) {
this.target.appendChild(cellContent);
}
} else {
this.debounce('remove-content', function() {
if (!this.isAttached && cellContent.parentNode) {
this.target.removeChild(cellContent);
}
}, 1);
}
}
},
Expand Down

0 comments on commit e01d53a

Please sign in to comment.