Skip to content

Commit e613ef2

Browse files
authored
fix: keep slot attribute when moving content between split layouts (#5021)
1 parent 74c2ae1 commit e613ef2

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎packages/split-layout/src/vaadin-split-layout.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ class SplitLayout extends ElementMixin(ThemableMixin(PolymerElement)) {
250250
/** @private */
251251
_cleanupNodes(nodes) {
252252
nodes.forEach((node) => {
253-
node.removeAttribute('slot');
253+
if (!(node.parentElement instanceof SplitLayout)) {
254+
node.removeAttribute('slot');
255+
}
254256
});
255257
}
256258

‎packages/split-layout/test/split-layout.test.js‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,28 @@ describe('removing nodes', () => {
333333
expect(first.hasAttribute('slot')).to.be.false;
334334
});
335335
});
336+
337+
describe('moving nodes between layouts', () => {
338+
beforeEach(async () => {
339+
splitLayout = fixtureSync(`
340+
<vaadin-split-layout>
341+
<div id="first">some content</div>
342+
<div id="second">some content</div>
343+
</vaadin-split-layout>
344+
`);
345+
await aTimeout(0);
346+
first = splitLayout.$.primary.assignedNodes({ flatten: true })[0];
347+
second = splitLayout.$.secondary.assignedNodes({ flatten: true })[0];
348+
});
349+
350+
it('should not clear slot attribute when moving to a different split layout', async () => {
351+
const otherLayout = fixtureSync(`
352+
<vaadin-split-layout></vaadin-split-layout>
353+
`);
354+
otherLayout.appendChild(second);
355+
otherLayout.appendChild(first);
356+
await nextFrame();
357+
expect(second.getAttribute('slot')).to.equal('primary');
358+
expect(first.getAttribute('slot')).to.equal('secondary');
359+
});
360+
});

0 commit comments

Comments
 (0)