Skip to content

Commit 088a771

Browse files
committed
Merge branch 'main' into scope-evaluate
2 parents 57f1886 + 489f463 commit 088a771

File tree

11 files changed

+52
-7
lines changed

11 files changed

+52
-7
lines changed

.changeset/brown-rockets-shake.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: invalidate parent effects when child effects update parent dependencies

.changeset/curvy-countries-flow.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: replace `undefined` with `void 0` to avoid edge case

.changeset/plenty-bats-lay.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: add `files` and `group` to HTMLInputAttributes in elements.d.ts

packages/svelte/elements.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,7 @@ export interface HTMLInputAttributes extends HTMLAttributes<HTMLInputElement> {
10761076
checked?: boolean | undefined | null;
10771077
dirname?: string | undefined | null;
10781078
disabled?: boolean | undefined | null;
1079+
files?: FileList | undefined | null;
10791080
form?: string | undefined | null;
10801081
formaction?: string | undefined | null;
10811082
formenctype?:
@@ -1087,6 +1088,7 @@ export interface HTMLInputAttributes extends HTMLAttributes<HTMLInputElement> {
10871088
formmethod?: 'dialog' | 'get' | 'post' | 'DIALOG' | 'GET' | 'POST' | undefined | null;
10881089
formnovalidate?: boolean | undefined | null;
10891090
formtarget?: string | undefined | null;
1091+
group?: any | undefined | null;
10901092
height?: number | string | undefined | null;
10911093
indeterminate?: boolean | undefined | null;
10921094
list?: string | undefined | null;

packages/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ export function VariableDeclaration(node, context) {
116116
}
117117

118118
const args = /** @type {CallExpression} */ (init).arguments;
119-
const value =
120-
args.length === 0 ? b.id('undefined') : /** @type {Expression} */ (context.visit(args[0]));
119+
const value = args.length > 0 ? /** @type {Expression} */ (context.visit(args[0])) : b.void0;
121120

122121
if (rune === '$state' || rune === '$state.raw') {
123122
/**

packages/svelte/src/compiler/phases/3-transform/server/visitors/CallExpression.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export function CallExpression(node, context) {
1313
const rune = get_rune(node, context.state.scope);
1414

1515
if (rune === '$host') {
16-
return b.id('undefined');
16+
return b.void0;
1717
}
1818

1919
if (rune === '$effect.tracking') {
20-
return b.literal(false);
20+
return b.false;
2121
}
2222

2323
if (rune === '$effect.root') {

packages/svelte/src/compiler/phases/3-transform/server/visitors/VariableDeclaration.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function VariableDeclaration(node, context) {
4545
) {
4646
const right = node.right.arguments.length
4747
? /** @type {Expression} */ (context.visit(node.right.arguments[0]))
48-
: b.id('undefined');
48+
: b.void0;
4949
return b.assignment_pattern(node.left, right);
5050
}
5151
}
@@ -75,8 +75,7 @@ export function VariableDeclaration(node, context) {
7575
}
7676

7777
const args = /** @type {CallExpression} */ (init).arguments;
78-
const value =
79-
args.length === 0 ? b.id('undefined') : /** @type {Expression} */ (context.visit(args[0]));
78+
const value = args.length > 0 ? /** @type {Expression} */ (context.visit(args[0])) : b.void0;
8079

8180
if (rune === '$derived.by') {
8281
declarations.push(

packages/svelte/src/compiler/utils/builders.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ export function unary(operator, argument) {
154154
return { type: 'UnaryExpression', argument, operator, prefix: true };
155155
}
156156

157+
export const void0 = unary('void', literal(0));
158+
157159
/**
158160
* @param {ESTree.Expression} test
159161
* @param {ESTree.Expression} consequent

packages/svelte/src/internal/client/runtime.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,14 @@ export function update_reaction(reaction) {
460460
// the same version
461461
if (previous_reaction !== null) {
462462
read_version++;
463+
464+
if (untracked_writes !== null) {
465+
if (previous_untracked_writes === null) {
466+
previous_untracked_writes = untracked_writes;
467+
} else {
468+
previous_untracked_writes.push(.../** @type {Source[]} */ (untracked_writes));
469+
}
470+
}
463471
}
464472

465473
return result;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
test({ assert, target, logs }) {
5+
assert.deepEqual(logs, ['Outer', 'Inner', 'Outer', 'Inner']);
6+
}
7+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script>
2+
let value = $state(0);
3+
4+
$effect.pre(() => {
5+
console.log("Outer");
6+
value;
7+
8+
$effect.pre(() => {
9+
console.log("Inner");
10+
value = 10;
11+
});
12+
});
13+
</script>

0 commit comments

Comments
 (0)