Skip to content

Commit 292f255

Browse files
committed
Merge branch 'async' into async-changeset
2 parents 3a5895b + ef28490 commit 292f255

File tree

33 files changed

+321
-135
lines changed

33 files changed

+321
-135
lines changed

.changeset/hip-singers-vanish.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/short-fireants-talk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ignore typescript abstract methods

documentation/docs/06-runtime/03-lifecycle-hooks.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ If a function is returned from `onMount`, it will be called when the component i
4545
4646
## `onDestroy`
4747

48-
> EXPORT_SNIPPET: svelte#onDestroy
49-
5048
Schedules a callback to run immediately before the component is unmounted.
5149

5250
Out of `onMount`, `beforeUpdate`, `afterUpdate` and `onDestroy`, this is the only one that runs inside a server-side component.

packages/svelte/CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# svelte
22

3+
## 5.20.0
4+
5+
### Minor Changes
6+
7+
- feat: SSR-safe ID generation with `$props.id()` ([#15185](https://github.com/sveltejs/svelte/pull/15185))
8+
9+
### Patch Changes
10+
11+
- fix: take private and public into account for `constant_assignment` of derived state ([#15276](https://github.com/sveltejs/svelte/pull/15276))
12+
13+
- fix: value/checked not correctly set using spread ([#15239](https://github.com/sveltejs/svelte/pull/15239))
14+
15+
- chore: tweak effect self invalidation logic, run transition dispatches without reactive context ([#15275](https://github.com/sveltejs/svelte/pull/15275))
16+
17+
- fix: use `importNode` to clone templates for Firefox ([#15272](https://github.com/sveltejs/svelte/pull/15272))
18+
19+
- fix: recurse into `$derived` for ownership validation ([#15166](https://github.com/sveltejs/svelte/pull/15166))
20+
321
## 5.19.10
422

523
### Patch Changes

packages/svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "svelte",
33
"description": "Cybernetically enhanced web apps",
44
"license": "MIT",
5-
"version": "5.19.10",
5+
"version": "5.20.0",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ const visitors = {
118118
delete node.implements;
119119
return context.next();
120120
},
121+
MethodDefinition(node, context) {
122+
if (node.abstract) {
123+
return b.empty;
124+
}
125+
return context.next();
126+
},
121127
VariableDeclaration(node, context) {
122128
if (node.declare) {
123129
return b.empty;

packages/svelte/src/compiler/phases/2-analyze/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface AnalysisState {
1919
component_slots: Set<string>;
2020
/** Information about the current expression/directive/block value */
2121
expression: ExpressionMetadata | null;
22-
derived_state: string[];
22+
derived_state: { name: string; private: boolean }[];
2323
function_depth: number;
2424

2525
// legacy stuff

packages/svelte/src/compiler/phases/2-analyze/visitors/Attribute.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ export function Attribute(node, context) {
2323
if (node.name === 'value' && parent.name === 'option') {
2424
mark_subtree_dynamic(context.path);
2525
}
26-
27-
// special case <img loading="lazy" />
28-
if (node.name === 'loading' && parent.name === 'img') {
29-
mark_subtree_dynamic(context.path);
30-
}
3126
}
3227

3328
if (is_event_attribute(node)) {

packages/svelte/src/compiler/phases/2-analyze/visitors/ClassBody.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { get_rune } from '../../scope.js';
77
* @param {Context} context
88
*/
99
export function ClassBody(node, context) {
10-
/** @type {string[]} */
10+
/** @type {{name: string, private: boolean}[]} */
1111
const derived_state = [];
1212

1313
for (const definition of node.body) {
@@ -18,7 +18,10 @@ export function ClassBody(node, context) {
1818
) {
1919
const rune = get_rune(definition.value, context.state.scope);
2020
if (rune === '$derived' || rune === '$derived.by') {
21-
derived_state.push(definition.key.name);
21+
derived_state.push({
22+
name: definition.key.name,
23+
private: definition.key.type === 'PrivateIdentifier'
24+
});
2225
}
2326
}
2427
}

packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @import { AssignmentExpression, Expression, Literal, Node, Pattern, PrivateIdentifier, Super, UpdateExpression, VariableDeclarator } from 'estree' */
1+
/** @import { AssignmentExpression, Expression, Identifier, Literal, Node, Pattern, PrivateIdentifier, Super, UpdateExpression, VariableDeclarator } from 'estree' */
22
/** @import { AST, Binding } from '#compiler' */
33
/** @import { AnalysisState, Context } from '../../types' */
44
/** @import { Scope } from '../../../scope' */
@@ -38,16 +38,22 @@ export function validate_assignment(node, argument, state) {
3838
e.snippet_parameter_assignment(node);
3939
}
4040
}
41-
4241
if (
4342
argument.type === 'MemberExpression' &&
4443
argument.object.type === 'ThisExpression' &&
4544
(((argument.property.type === 'PrivateIdentifier' || argument.property.type === 'Identifier') &&
46-
state.derived_state.includes(argument.property.name)) ||
45+
state.derived_state.some(
46+
(derived) =>
47+
derived.name === /** @type {PrivateIdentifier | Identifier} */ (argument.property).name &&
48+
derived.private === (argument.property.type === 'PrivateIdentifier')
49+
)) ||
4750
(argument.property.type === 'Literal' &&
4851
argument.property.value &&
4952
typeof argument.property.value === 'string' &&
50-
state.derived_state.includes(argument.property.value)))
53+
state.derived_state.some(
54+
(derived) =>
55+
derived.name === /** @type {Literal} */ (argument.property).value && !derived.private
56+
)))
5157
) {
5258
e.constant_assignment(node, 'derived state');
5359
}

0 commit comments

Comments
 (0)