summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chell <im.chell@outlook.com> 2023-05-01 16:49:23 +0200
committerGravatar GitHub <noreply@github.com> 2023-05-01 10:49:23 -0400
commit50975f2ea3a59f9e023cc631a9372c0c7986eec9 (patch)
tree1ba115953ba1abe2085de42f3795a9cbf8c92cf3
parentdc062f6695ce577dc569781fc0678c903012c336 (diff)
downloadastro-50975f2ea3a59f9e023cc631a9372c0c7986eec9.tar.gz
astro-50975f2ea3a59f9e023cc631a9372c0c7986eec9.tar.zst
astro-50975f2ea3a59f9e023cc631a9372c0c7986eec9.zip
Fix slot tags uncleaned in HTML String (#6948)
* fix: slot regex * add slot test * change set * add test
-rw-r--r--.changeset/sharp-jobs-grow.md5
-rw-r--r--packages/astro/src/runtime/server/render/component.ts2
-rw-r--r--packages/astro/test/astro-slot-with-client.test.js6
3 files changed, 12 insertions, 1 deletions
diff --git a/.changeset/sharp-jobs-grow.md b/.changeset/sharp-jobs-grow.md
new file mode 100644
index 000000000..ab0cf961d
--- /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 1c427bf2a..cc8851522 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 12e630548..4ad26dee4 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);
+ });
});