From 7e5bdf85211ff1a994b8e873c35883ff46537c53 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Thu, 6 Aug 2020 17:50:00 +0000 Subject: [PATCH] fix(core): update --- test/test.ts | 4 ++-- ts/smartssr.function.serialize.ts | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/test/test.ts b/test/test.ts index ea5f73c..ebf090f 100644 --- a/test/test.ts +++ b/test/test.ts @@ -13,13 +13,13 @@ tap.test('should start the smartssr instance', async () => { await testSSRInstance.start(); }); -tap.test('should render central.eu', async (tools) => { +tap.skip.test('should render central.eu', async (tools) => { await testSSRInstance.renderPage( 'https://central.eu/article/5e76873b9cf69b7bf6bc78bc/Introducing%3A%20central.eu' ); }); -tap.skip.test('should render lossless.com', async () => { +tap.test('should render lossless.com', async () => { await testSSRInstance.renderPage('https://lossless.com'); }); diff --git a/ts/smartssr.function.serialize.ts b/ts/smartssr.function.serialize.ts index 968bec7..9d2e044 100644 --- a/ts/smartssr.function.serialize.ts +++ b/ts/smartssr.function.serialize.ts @@ -42,11 +42,18 @@ export function serializeFunction(rootNode) { const slots = nodeArg.shadowRoot.querySelectorAll('slot'); // handle slot element + const slotsForMove: HTMLSlotElement[] = []; slots.forEach((slot) => { - nodeArg.childNodes.forEach((lightNode) => slot.parentNode.insertBefore(lightNode, slot)); - slot.parentNode.removeChild(slot); + slotsForMove.push(slot); }); + + for (const slot of slotsForMove) { + const slottedLightNodesForMove = []; + slot.assignedNodes().forEach((lightNode) => slottedLightNodesForMove.push(lightNode)); + slottedLightNodesForMove.forEach((lightNode) => slot.parentNode.insertBefore(lightNode, slot)); + } + // lets modify the css const childNodes = nodeArg.shadowRoot.childNodes; // tslint:disable-next-line: prefer-for-of