diff --git a/documentation/docs/01-getting-started/01-introduction.md b/documentation/docs/01-getting-started/01-introduction.md index 73766b1b9bc9..01fe9ca8af4a 100644 --- a/documentation/docs/01-getting-started/01-introduction.md +++ b/documentation/docs/01-getting-started/01-introduction.md @@ -23,7 +23,7 @@ SvelteKit will handle calling [the Svelte compiler](https://www.npmjs.com/packag If you don't want to use SvelteKit for some reason, you can also use Svelte with Vite (but without SvelteKit) by running `npm create vite@latest` and selecting the `svelte` option. With this, `npm run build` will generate HTML, JS and CSS files inside the `dist` directory. In most cases, you will probably need to [choose a routing library](/faq#is-there-a-router) as well. -Alternatively, there are [plugins for all the major web bundlers](https://sveltesociety.dev/packages?category=bundler-plugins) to handle Svelte compilation — which will output `.js` and `.css` that you can insert into your HTML — but most others won't handle SSR. +Alternatively, there are [plugins for all the major web bundlers](https://sveltesociety.dev/packages?category=build-plugins) to handle Svelte compilation — which will output `.js` and `.css` that you can insert into your HTML — but most others won't handle SSR. ## Editor tooling diff --git a/packages/svelte/CHANGELOG.md b/packages/svelte/CHANGELOG.md index b88e4bff17cd..dd227d1966c6 100644 --- a/packages/svelte/CHANGELOG.md +++ b/packages/svelte/CHANGELOG.md @@ -1,5 +1,11 @@ # svelte +## 4.2.12 + +### Patch Changes + +- fix: properly update `svelte:component` props when there are spread props ([#10604](https://github.com/sveltejs/svelte/pull/10604)) + ## 4.2.11 ### Patch Changes diff --git a/packages/svelte/package.json b/packages/svelte/package.json index 69ba08c6c72d..a576e1d659e3 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "4.2.11", + "version": "4.2.12", "description": "Cybernetically enhanced web apps", "type": "module", "module": "src/runtime/index.js", diff --git a/packages/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.js b/packages/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.js index d5cf8341dcdd..e29050bdc588 100644 --- a/packages/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.js +++ b/packages/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.js @@ -277,14 +277,13 @@ export default class InlineComponentWrapper extends Wrapper { // statements will become switch_props function body // rewrite last statement, add props update logic statements[statements.length - 1] = b` + for (let #i = 0; #i < ${levels}.length; #i += 1) { + ${props} = @assign(${props}, ${levels}[#i]); + } if (#dirty !== undefined && ${condition}) { - ${props} = @get_spread_update(${levels}, [ + ${props} = @assign(${props}, @get_spread_update(${levels}, [ ${changes} - ]); - } else { - for (let #i = 0; #i < ${levels}.length; #i += 1) { - ${props} = @assign(${props}, ${levels}[#i]); - } + ])); } `; } diff --git a/packages/svelte/src/shared/version.js b/packages/svelte/src/shared/version.js index e29a4911159a..b30c9523bdad 100644 --- a/packages/svelte/src/shared/version.js +++ b/packages/svelte/src/shared/version.js @@ -6,5 +6,5 @@ * https://svelte.dev/docs/svelte-compiler#svelte-version * @type {string} */ -export const VERSION = '4.2.11'; +export const VERSION = '4.2.12'; export const PUBLIC_VERSION = '4'; diff --git a/packages/svelte/test/runtime/samples/dynamic-component-spread-props/Comp1.svelte b/packages/svelte/test/runtime/samples/dynamic-component-spread-props/Comp1.svelte index d4fe28a8a370..e87e7ec69912 100644 --- a/packages/svelte/test/runtime/samples/dynamic-component-spread-props/Comp1.svelte +++ b/packages/svelte/test/runtime/samples/dynamic-component-spread-props/Comp1.svelte @@ -1,5 +1,9 @@

value(1) = {value}

+

foo={foo}

+

typeof cb={typeof cb}

diff --git a/packages/svelte/test/runtime/samples/dynamic-component-spread-props/Comp2.svelte b/packages/svelte/test/runtime/samples/dynamic-component-spread-props/Comp2.svelte index 07d41f3d8464..06c4c7acfe74 100644 --- a/packages/svelte/test/runtime/samples/dynamic-component-spread-props/Comp2.svelte +++ b/packages/svelte/test/runtime/samples/dynamic-component-spread-props/Comp2.svelte @@ -1,5 +1,9 @@

value(2) = {value}

+

foo={foo}

+

typeof cb={typeof cb}

diff --git a/packages/svelte/test/runtime/samples/dynamic-component-spread-props/_config.js b/packages/svelte/test/runtime/samples/dynamic-component-spread-props/_config.js index d5ba1ef64b58..c09efb851bc7 100644 --- a/packages/svelte/test/runtime/samples/dynamic-component-spread-props/_config.js +++ b/packages/svelte/test/runtime/samples/dynamic-component-spread-props/_config.js @@ -1,6 +1,8 @@ export default { html: `

value(1) = 1

+

foo=bar

+

typeof cb=function

`, @@ -11,6 +13,8 @@ export default { target.innerHTML, `

value(2) = 2

+

foo=bar

+

typeof cb=function

` ); @@ -19,6 +23,8 @@ export default { target.innerHTML, `

value(1) = 1

+

foo=bar

+

typeof cb=function

` ); diff --git a/packages/svelte/test/runtime/samples/dynamic-component-spread-props/main.svelte b/packages/svelte/test/runtime/samples/dynamic-component-spread-props/main.svelte index b8c45c83a084..082ebbcda26e 100644 --- a/packages/svelte/test/runtime/samples/dynamic-component-spread-props/main.svelte +++ b/packages/svelte/test/runtime/samples/dynamic-component-spread-props/main.svelte @@ -5,8 +5,10 @@ let view = Comp1; $: props = view === Comp1 ? { value: 1 } : { value: 2 }; + const bar = "bar"; + function cb() {} - +