mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
Fix slot tags uncleaned in HTML String (#6948)
* fix: slot regex * add slot test * change set * add test
This commit is contained in:
parent
dc062f6695
commit
50975f2ea3
3 changed files with 12 additions and 1 deletions
5
.changeset/sharp-jobs-grow.md
Normal file
5
.changeset/sharp-jobs-grow.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"astro": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Placeholders for slots are cleaned in HTML String that is rendered
|
|
@ -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') {
|
if (isPage || renderer?.name === 'astro:jsx') {
|
||||||
yield html;
|
yield html;
|
||||||
} else if (html && html.length > 0) {
|
} else if (html && html.length > 0) {
|
||||||
yield markHTMLString(html.replace(/\<\/?astro-slot\>/g, ''));
|
yield markHTMLString(html.replace(/\<\/?astro-slot\b[^>]*>/g, ''));
|
||||||
} else {
|
} else {
|
||||||
yield '';
|
yield '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,10 @@ describe('Slots with client: directives', () => {
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
expect($('script')).to.have.a.lengthOf(1);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue