summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Happydev <81974850+MoustaphaDev@users.noreply.github.com> 2024-02-06 15:44:02 +0000
committerGravatar GitHub <noreply@github.com> 2024-02-06 16:44:02 +0100
commitc53a31321a935e4be04809046d7e0ba3cc41b272 (patch)
tree0b74bb486d875574d0ddcf1c51f1e6ba896f598d
parent56db6ae24686c3860743c7d55eaf14cd9e98be6b (diff)
downloadastro-c53a31321a935e4be04809046d7e0ba3cc41b272.tar.gz
astro-c53a31321a935e4be04809046d7e0ba3cc41b272.tar.zst
astro-c53a31321a935e4be04809046d7e0ba3cc41b272.zip
Revert "fix(compiler): Support dynamic slot names (#9605)" (#9999)
* Revert "fix(compiler): Support dynamic slot names (#9605)" This reverts commit 8ce40a417c854d9e6a4fa7d5a85d50a6436b4a3c. * chore: changeset * Update .changeset/weak-pans-sit.md * chore: bump compiler version * fix failing test We were expecting the source code to produce an error, but in 2.4.0 of the compiler, that generates valid code --------- Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
-rw-r--r--.changeset/weak-pans-sit.md5
-rw-r--r--packages/astro/package.json2
-rw-r--r--packages/astro/src/runtime/server/index.ts5
-rw-r--r--packages/astro/test/astro-slots.test.js20
-rw-r--r--packages/astro/test/fixtures/astro-slots/src/pages/dynamic-for.astro24
-rw-r--r--packages/astro/test/fixtures/astro-slots/src/pages/dynamic-map.astro17
-rw-r--r--pnpm-lock.yaml10
7 files changed, 12 insertions, 71 deletions
diff --git a/.changeset/weak-pans-sit.md b/.changeset/weak-pans-sit.md
new file mode 100644
index 000000000..d70d53948
--- /dev/null
+++ b/.changeset/weak-pans-sit.md
@@ -0,0 +1,5 @@
+---
+"astro": patch
+---
+
+Rollbacks the feature which allowed to dynamically generate slots with variable slot names due to unexpected regressions.
diff --git a/packages/astro/package.json b/packages/astro/package.json
index 19cb50300..22c503e7b 100644
--- a/packages/astro/package.json
+++ b/packages/astro/package.json
@@ -114,7 +114,7 @@
"test:e2e:match": "playwright test -g"
},
"dependencies": {
- "@astrojs/compiler": "^2.5.0",
+ "@astrojs/compiler": "^2.5.3",
"@astrojs/internal-helpers": "workspace:*",
"@astrojs/markdown-remark": "workspace:*",
"@astrojs/telemetry": "workspace:*",
diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts
index e92f33c84..81d05987a 100644
--- a/packages/astro/src/runtime/server/index.ts
+++ b/packages/astro/src/runtime/server/index.ts
@@ -45,11 +45,8 @@ import { addAttribute, Renderer } from './render/index.js';
export function mergeSlots(...slotted: unknown[]) {
const slots: Record<string, () => any> = {};
- for (let slot of slotted) {
+ for (const slot of slotted) {
if (!slot) continue;
- if (Array.isArray(slot)) {
- slot = mergeSlots(...slot);
- }
if (typeof slot === 'object') {
Object.assign(slots, slot);
} else if (typeof slot === 'function') {
diff --git a/packages/astro/test/astro-slots.test.js b/packages/astro/test/astro-slots.test.js
index 7610e7305..69a0025e1 100644
--- a/packages/astro/test/astro-slots.test.js
+++ b/packages/astro/test/astro-slots.test.js
@@ -30,26 +30,6 @@ describe('Slots', () => {
expect($('#default').text().trim()).to.equal('Default');
});
- it('Dynamic named slots work with map work', async () => {
- const html = await fixture.readFile('/dynamic-map/index.html');
- const $ = cheerio.load(html);
-
- expect($('#a').text().trim()).to.equal('A');
- expect($('#b').text().trim()).to.equal('B');
- expect($('#c').text().trim()).to.equal('C');
- expect($('#default').text().trim()).to.equal('Default');
- });
-
- it('Dynamic named slots work with for loop', async () => {
- const html = await fixture.readFile('/dynamic-for/index.html');
- const $ = cheerio.load(html);
-
- expect($('#a').text().trim()).to.equal('A');
- expect($('#b').text().trim()).to.equal('B');
- expect($('#c').text().trim()).to.equal('C');
- expect($('#default').text().trim()).to.equal('Default');
- });
-
it('Conditional named slots work', async () => {
const html = await fixture.readFile('/conditional/index.html');
const $ = cheerio.load(html);
diff --git a/packages/astro/test/fixtures/astro-slots/src/pages/dynamic-for.astro b/packages/astro/test/fixtures/astro-slots/src/pages/dynamic-for.astro
deleted file mode 100644
index f7e48735d..000000000
--- a/packages/astro/test/fixtures/astro-slots/src/pages/dynamic-for.astro
+++ /dev/null
@@ -1,24 +0,0 @@
----
-import Slotted from '../components/Slotted.astro';
-
-const slotNames = ['a', 'b', 'c']
----
-
-<html>
- <head>
- <!-- Head Stuff -->
- </head>
- <body>
- <Slotted>
- {()=>{
- const slots:any[] = [];
- for (const slotName of slotNames) {
- slots.push(<span slot={slotName}>{slotName.toUpperCase()}</span>);
- }
- return slots;
- }
- }
- <span>Default</span>
- </Slotted>
- </body>
-</html>
diff --git a/packages/astro/test/fixtures/astro-slots/src/pages/dynamic-map.astro b/packages/astro/test/fixtures/astro-slots/src/pages/dynamic-map.astro
deleted file mode 100644
index 3917d73dd..000000000
--- a/packages/astro/test/fixtures/astro-slots/src/pages/dynamic-map.astro
+++ /dev/null
@@ -1,17 +0,0 @@
----
-import Slotted from '../components/Slotted.astro';
-
-const slots = ['a', 'b', 'c']
----
-
-<html>
- <head>
- <!-- Head Stuff -->
- </head>
- <body>
- <Slotted>
- {slots.map((slotName)=><span slot={slotName}>{slotName.toUpperCase()}</span>)}
- <span>Default</span>
- </Slotted>
- </body>
-</html>
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d0d0cb211..ab9a78504 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -492,8 +492,8 @@ importers:
packages/astro:
dependencies:
'@astrojs/compiler':
- specifier: ^2.5.0
- version: 2.5.0
+ specifier: ^2.5.3
+ version: 2.5.3
'@astrojs/internal-helpers':
specifier: workspace:*
version: link:../internal-helpers
@@ -5329,8 +5329,8 @@ packages:
resolution: {integrity: sha512-o/ObKgtMzl8SlpIdzaxFnt7SATKPxu4oIP/1NL+HDJRzxfJcAkOTAb/ZKMRyULbz4q+1t2/DAebs2Z1QairkZw==}
dev: true
- /@astrojs/compiler@2.5.0:
- resolution: {integrity: sha512-ZDluNgMIJT+z+HJcZ6QEJ/KqaFkTkrb+Za6c6VZs8G/nb1LBErL14/iU5EVJ9yu25i4QCLweuBJ3m5df34gZJg==}
+ /@astrojs/compiler@2.5.3:
+ resolution: {integrity: sha512-jzj01BRv/fmo+9Mr2FhocywGzEYiyiP2GVHje1ziGNU6c97kwhYGsnvwMkHrncAy9T9Vi54cjaMK7UE4ClX4vA==}
/@astrojs/language-server@2.5.5(prettier-plugin-astro@0.12.3)(prettier@3.1.1)(typescript@5.2.2):
resolution: {integrity: sha512-hk7a8S7bpf//BOA6mMjiYqi/eiYtGPfUfw59eVXdutdRFdwDHtu4jcsLu43ZaId56pAcE8qFjIvJxySvzcxiUA==}
@@ -5344,7 +5344,7 @@ packages:
prettier-plugin-astro:
optional: true
dependencies:
- '@astrojs/compiler': 2.5.0
+ '@astrojs/compiler': 2.5.3
'@jridgewell/sourcemap-codec': 1.4.15
'@volar/kit': 1.10.10(typescript@5.2.2)
'@volar/language-core': 1.10.10