diff --git a/.changeset/sharp-jobs-grow.md b/.changeset/sharp-jobs-grow.md new file mode 100644 index 0000000000..ab0cf961d3 --- /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 diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts index 1c427bf2a4..cc88515226 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 ''; } diff --git a/packages/astro/test/astro-slot-with-client.test.js b/packages/astro/test/astro-slot-with-client.test.js index 12e630548c..4ad26dee41 100644 --- a/packages/astro/test/astro-slot-with-client.test.js +++ b/packages/astro/test/astro-slot-with-client.test.js @@ -16,4 +16,10 @@ describe('Slots with client: directives', () => { const $ = cheerio.load(html); 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); + }); });