Skip to content

Commit 50975f2

Browse files
authored
Fix slot tags uncleaned in HTML String (#6948)
* fix: slot regex * add slot test * change set * add test
1 parent dc062f6 commit 50975f2

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

.changeset/sharp-jobs-grow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"astro": patch
3+
---
4+
5+
Placeholders for slots are cleaned in HTML String that is rendered

packages/astro/src/runtime/server/render/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
263263
if (isPage || renderer?.name === 'astro:jsx') {
264264
yield html;
265265
} else if (html && html.length > 0) {
266-
yield markHTMLString(html.replace(/\<\/?astro-slot\>/g, ''));
266+
yield markHTMLString(html.replace(/\<\/?astro-slot\b[^>]*>/g, ''));
267267
} else {
268268
yield '';
269269
}

packages/astro/test/astro-slot-with-client.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ describe('Slots with client: directives', () => {
1616
const $ = cheerio.load(html);
1717
expect($('script')).to.have.a.lengthOf(1);
1818
});
19+
20+
it('Astro slot tags are cleaned', async () => {
21+
const html = await fixture.readFile('/index.html');
22+
const $ = cheerio.load(html);
23+
expect($('astro-slot')).to.have.a.lengthOf(0);
24+
});
1925
});

0 commit comments

Comments
 (0)