Skip to content

Commit

Permalink
fix: cleanup slot attribute on removed nodes (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Feb 28, 2022
1 parent ebf04bb commit b4ff18e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/vaadin-split-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,17 @@
/** @protected */
ready() {
super.ready();
new Polymer.FlattenedNodesObserver(this, this._processChildren);
new Polymer.FlattenedNodesObserver(this, (info) => {
this._cleanupNodes(info.removedNodes);
this._processChildren();
});
}

/** @private */
_cleanupNodes(nodes) {
nodes.forEach((node) => {
node.removeAttribute('slot');
});
}

/** @private */
Expand Down
18 changes: 18 additions & 0 deletions test/vaadin-split-layout_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,24 @@

});

describe('removing nodes', () => {
beforeEach(done => {
splitLayout = fixture('split-layout');
setTimeout(() => {
first = splitLayout.$.primary.assignedNodes({flatten: true})[0];
second = splitLayout.$.secondary.assignedNodes({flatten: true})[0];
done();
}, 1);
});

it('should remove slot attribute from the removed node', (done) => {
splitLayout.removeChild(first);
setTimeout(() => {
expect(first.hasAttribute('slot')).to.be.false;
done();
});
});
});
</script>
</body>
</html>

0 comments on commit b4ff18e

Please sign in to comment.