diff --git a/.changeset/weak-pans-sit.md b/.changeset/weak-pans-sit.md new file mode 100644 index 000000000000..d70d539482c8 --- /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 19cb50300da5..22c503e7b8ac 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 e92f33c842a7..81d05987adb8 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 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 7610e73059b9..69a0025e1f27 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 f7e48735dfc5..000000000000 --- 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'] ---- - - - - - - - - {()=>{ - const slots:any[] = []; - for (const slotName of slotNames) { - slots.push({slotName.toUpperCase()}); - } - return slots; - } - } - Default - - - 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 3917d73dd860..000000000000 --- 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'] ---- - - - - - - - - {slots.map((slotName)=>{slotName.toUpperCase()})} - Default - - - diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d0d0cb211eb2..ab9a78504173 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