From 008fc13ffbf16422da230b84265d2ddce28b7420 Mon Sep 17 00:00:00 2001 From: Chell Date: Sat, 29 Apr 2023 23:32:40 +0200 Subject: [PATCH 1/4] fix: slot regex --- packages/astro/src/runtime/server/render/component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts index 1c427bf2a495..cc8851522644 100644 --- a/packages/astro/src/runtime/server/render/component.ts +++ b/packages/astro/src/runtime/server/render/component.ts @@ -263,7 +263,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr if (isPage || renderer?.name === 'astro:jsx') { yield html; } else if (html && html.length > 0) { - yield markHTMLString(html.replace(/\<\/?astro-slot\>/g, '')); + yield markHTMLString(html.replace(/\<\/?astro-slot\b[^>]*>/g, '')); } else { yield ''; } From 3f0e160903e0de94a4f0772e65d60c53fa157f49 Mon Sep 17 00:00:00 2001 From: Chell Date: Sun, 30 Apr 2023 00:04:39 +0200 Subject: [PATCH 2/4] add slot test --- packages/astro/test/astro-slot-with-client.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/astro/test/astro-slot-with-client.test.js b/packages/astro/test/astro-slot-with-client.test.js index 12e630548c23..db6467c9751f 100644 --- a/packages/astro/test/astro-slot-with-client.test.js +++ b/packages/astro/test/astro-slot-with-client.test.js @@ -14,6 +14,13 @@ describe('Slots with client: directives', () => { it('Tags of dynamic tags works', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); + console.log($('script')); expect($('script')).to.have.a.lengthOf(1); }); + + it('Astro slot tags are cleaned', async () => { + const html = await fixture.readFile('/index.html'); + const $ = cheerio.load(html); + expect($('astro-slot')).to.have.a.lengthOf(0); + }); }); From 9726b44419ea0969e64ee8240090e302d4ac3200 Mon Sep 17 00:00:00 2001 From: Chell Date: Sun, 30 Apr 2023 00:18:28 +0200 Subject: [PATCH 3/4] change set --- .changeset/sharp-jobs-grow.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sharp-jobs-grow.md diff --git a/.changeset/sharp-jobs-grow.md b/.changeset/sharp-jobs-grow.md new file mode 100644 index 000000000000..ab0cf961d39b --- /dev/null +++ b/.changeset/sharp-jobs-grow.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Placeholders for slots are cleaned in HTML String that is rendered From dfa6cd700d60572717ab52d27577c1e62f3358bf Mon Sep 17 00:00:00 2001 From: Chell Date: Sun, 30 Apr 2023 00:49:18 +0200 Subject: [PATCH 4/4] add test --- packages/astro/test/astro-slot-with-client.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/astro/test/astro-slot-with-client.test.js b/packages/astro/test/astro-slot-with-client.test.js index db6467c9751f..4ad26dee41ab 100644 --- a/packages/astro/test/astro-slot-with-client.test.js +++ b/packages/astro/test/astro-slot-with-client.test.js @@ -14,7 +14,6 @@ describe('Slots with client: directives', () => { it('Tags of dynamic tags works', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); - console.log($('script')); expect($('script')).to.have.a.lengthOf(1); });