diff --git a/.changeset/rude-drinks-relate.md b/.changeset/rude-drinks-relate.md deleted file mode 100644 index d0eab6ba11..0000000000 --- a/.changeset/rude-drinks-relate.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'svelte': patch ---- - -fix: correctly transform reassignments to class fields in SSR mode diff --git a/documentation/docs/07-misc/07-v5-migration-guide.md b/documentation/docs/07-misc/07-v5-migration-guide.md index e502b7921a..c24c1febee 100644 --- a/documentation/docs/07-misc/07-v5-migration-guide.md +++ b/documentation/docs/07-misc/07-v5-migration-guide.md @@ -833,9 +833,9 @@ Svelte 5 is more strict about the HTML structure and will throw a compiler error Assignments to destructured parts of a `@const` declaration are no longer allowed. It was an oversight that this was ever allowed. -### :is(...) and :where(...) are scoped +### :is(...), :has(...), and :where(...) are scoped -Previously, Svelte did not analyse selectors inside `:is(...)` and `:where(...)`, effectively treating them as global. Svelte 5 analyses them in the context of the current component. As such, some selectors may now be treated as unused if they were relying on this treatment. To fix this, use `:global(...)` inside the `:is(...)/:where(...)` selectors. +Previously, Svelte did not analyse selectors inside `:is(...)`, `:has(...)`, and `:where(...)`, effectively treating them as global. Svelte 5 analyses them in the context of the current component. As such, some selectors may now be treated as unused if they were relying on this treatment. To fix this, use `:global(...)` inside the `:is(...)/:has(...)/:where(...)` selectors. When using Tailwind's `@apply` directive, add a `:global` selector to preserve rules that use Tailwind-generated `:is(...)` selectors: diff --git a/package.json b/package.json index 70e85438f0..62581782d7 100644 --- a/package.json +++ b/package.json @@ -15,13 +15,10 @@ }, "scripts": { "build": "pnpm -r --filter=./packages/* build", - "build:sites": "pnpm -r --filter=./sites/* build", - "preview-site": "npm run build --prefix sites/svelte-5-preview", "check": "cd packages/svelte && pnpm build && cd ../../ && pnpm -r check", "lint": "eslint && prettier --check .", "format": "prettier --write .", "test": "vitest run", - "test-output": "vitest run --coverage --reporter=json --outputFile=sites/svelte-5-preview/src/routes/status/results.json", "changeset:version": "changeset version && pnpm -r generate:version && git add --all", "changeset:publish": "changeset publish", "bench": "node --allow-natives-syntax ./benchmarking/run.js", diff --git a/packages/svelte/CHANGELOG.md b/packages/svelte/CHANGELOG.md index 4623f64766..c272603457 100644 --- a/packages/svelte/CHANGELOG.md +++ b/packages/svelte/CHANGELOG.md @@ -1,5 +1,25 @@ # svelte +## 5.33.14 + +### Patch Changes + +- Revert "feat: enable TS autocomplete for Svelte HTML element definitions" ([#16063](https://github.com/sveltejs/svelte/pull/16063)) + +- fix: destructuring snippet arguments ([#16068](https://github.com/sveltejs/svelte/pull/16068)) + +## 5.33.13 + +### Patch Changes + +- fix: avoid recursion error in `EachBlock` visitor ([#16058](https://github.com/sveltejs/svelte/pull/16058)) + +## 5.33.12 + +### Patch Changes + +- fix: correctly transform reassignments to class fields in SSR mode ([#16051](https://github.com/sveltejs/svelte/pull/16051)) + ## 5.33.11 ### Patch Changes diff --git a/packages/svelte/elements.d.ts b/packages/svelte/elements.d.ts index 0172b0e358..7a7889ad9e 100644 --- a/packages/svelte/elements.d.ts +++ b/packages/svelte/elements.d.ts @@ -2066,7 +2066,7 @@ export interface SvelteHTMLElements { failed?: import('svelte').Snippet<[error: unknown, reset: () => void]>; }; - [name: string & {}]: { [name: string]: any }; + [name: string]: { [name: string]: any }; } export type ClassValue = string | import('clsx').ClassArray | import('clsx').ClassDictionary; diff --git a/packages/svelte/package.json b/packages/svelte/package.json index 7c74c6147a..4d5ca63b17 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -2,7 +2,7 @@ "name": "svelte", "description": "Cybernetically enhanced web apps", "license": "MIT", - "version": "5.33.11", + "version": "5.33.14", "type": "module", "types": "./types/index.d.ts", "engines": { diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/EachBlock.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/EachBlock.js index 0ebfa563cf..e6a83921b1 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/EachBlock.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/EachBlock.js @@ -77,6 +77,9 @@ export function EachBlock(node, context) { * @returns {void} */ function collect_transitive_dependencies(binding, bindings) { + if (bindings.has(binding)) { + return; + } bindings.add(binding); if (binding.kind === 'legacy_reactive') { diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/SnippetBlock.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/SnippetBlock.js index 0809aa21b2..203cf62b37 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/SnippetBlock.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/SnippetBlock.js @@ -57,7 +57,7 @@ export function SnippetBlock(node, context) { for (const path of paths) { const name = /** @type {Identifier} */ (path.node).name; const needs_derived = path.has_default_value; // to ensure that default value is only called once - const fn = b.thunk(/** @type {Expression} */ (context.visit(path.expression))); + const fn = b.thunk(/** @type {Expression} */ (context.visit(path.expression, child_state))); declarations.push(b.let(path.node, needs_derived ? b.call('$.derived_safe_equal', fn) : fn)); diff --git a/packages/svelte/src/version.js b/packages/svelte/src/version.js index 4cbf73e7f9..4c6213b0ce 100644 --- a/packages/svelte/src/version.js +++ b/packages/svelte/src/version.js @@ -4,5 +4,5 @@ * The current version, as set in package.json. * @type {string} */ -export const VERSION = '5.33.11'; +export const VERSION = '5.33.14'; export const PUBLIC_VERSION = '5'; diff --git a/packages/svelte/svelte-html.d.ts b/packages/svelte/svelte-html.d.ts index 6e37cc93e8..5042eaa4b8 100644 --- a/packages/svelte/svelte-html.d.ts +++ b/packages/svelte/svelte-html.d.ts @@ -8,7 +8,7 @@ import * as svelteElements from './elements.js'; /** * @internal do not use */ -type HTMLProps = Omit< +type HTMLProps = Omit< import('./elements.js').SvelteHTMLElements[Property], keyof Override > & @@ -250,7 +250,7 @@ declare global { }; // don't type svelte:options, it would override the types in svelte/elements and it isn't extendable anyway - [name: string & {}]: { [name: string]: any }; + [name: string]: { [name: string]: any }; } } } diff --git a/packages/svelte/tests/html_equal.js b/packages/svelte/tests/html_equal.js index b5e18fdd42..6948d8db32 100644 --- a/packages/svelte/tests/html_equal.js +++ b/packages/svelte/tests/html_equal.js @@ -26,6 +26,7 @@ function clean_children(node, opts) { }); attributes.forEach((attr) => { + // Strip out the special onload/onerror hydration events from the test output if ((attr.name === 'onload' || attr.name === 'onerror') && attr.value === 'this.__e=event') { return; } @@ -67,6 +68,7 @@ function clean_children(node, opts) { continue; } + // add newlines for better readability and potentially recurse into children if (child.nodeType === 1 || child.nodeType === 8) { if (previous?.nodeType === 3) { const prev = /** @type {Text} */ (previous); @@ -95,8 +97,9 @@ function clean_children(node, opts) { text.data = text.data.trimEnd(); } + // indent code for better readability if (has_element_children && node.parentNode) { - node.innerHTML = `\n\t${node.innerHTML.replace(/\n/g, '\n\t')}\n`; + node.innerHTML = `\n\ ${node.innerHTML.replace(/\n/g, '\n ')}\n`; } if (template) { diff --git a/packages/svelte/tests/runtime-runes/samples/snippet-destructure-array/_config.js b/packages/svelte/tests/runtime-runes/samples/snippet-destructure-array/_config.js new file mode 100644 index 0000000000..05e3e80b79 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/snippet-destructure-array/_config.js @@ -0,0 +1,5 @@ +import { test } from '../../test'; + +export default test({ + html: `a` +}); diff --git a/packages/svelte/tests/runtime-runes/samples/snippet-destructure-array/main.svelte b/packages/svelte/tests/runtime-runes/samples/snippet-destructure-array/main.svelte new file mode 100644 index 0000000000..37345c629e --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/snippet-destructure-array/main.svelte @@ -0,0 +1,9 @@ + + +{#snippet content([x])} + {x} +{/snippet} + +{@render content(array)} \ No newline at end of file