Skip to content

Commit 13a9043

Browse files
committed
fix conflict
2 parents 5dd81cd + dee5bed commit 13a9043

File tree

10 files changed

+44
-16
lines changed

10 files changed

+44
-16
lines changed

.changeset/chilled-pumas-invite.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: apply keyed validation only for keyed each

.changeset/pre.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"fresh-weeks-trade",
3030
"funny-wombats-argue",
3131
"good-pianos-jump",
32+
"green-eggs-approve",
3233
"green-hounds-play",
3334
"honest-icons-change",
3435
"hungry-dots-fry",
@@ -59,11 +60,13 @@
5960
"sour-rules-march",
6061
"strong-lemons-provide",
6162
"tall-shrimps-worry",
63+
"ten-worms-reflect",
6264
"thirty-flowers-sit",
6365
"thirty-ghosts-fix",
6466
"thirty-impalas-repair",
6567
"tiny-kings-whisper",
6668
"two-falcons-buy",
69+
"wet-games-fly",
6770
"wicked-clouds-exercise",
6871
"wicked-doors-train"
6972
]

.changeset/thirty-wombats-relax.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: improve each block index handling

packages/svelte/CHANGELOG.md

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

3+
## 5.0.0-next.12
4+
5+
### Patch Changes
6+
7+
- fix: adjust mount and createRoot types ([`63e583184`](https://github.com/sveltejs/svelte/commit/63e58318460dbb3485df93d15beb2779a86d2c9a))
8+
9+
- fix: remove constructor overload ([`cb4b1f0a1`](https://github.com/sveltejs/svelte/commit/cb4b1f0a189803bed04adcb90fbd4334782e8469))
10+
11+
- fix: type-level back-compat for default slot and children prop ([`a3bc7d569`](https://github.com/sveltejs/svelte/commit/a3bc7d5698425ec9dde86eb302f2fd56d9da8f96))
12+
313
## 5.0.0-next.11
414

515
### 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.0.0-next.11",
5+
"version": "5.0.0-next.12",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,19 +2282,19 @@ export const template_visitors = {
22822282
)
22832283
: b.literal(null);
22842284

2285-
if (context.state.options.dev && key_function.type !== 'Literal') {
2286-
context.state.init.push(
2287-
b.stmt(b.call('$.validate_each_keys', b.thunk(collection), key_function))
2288-
);
2289-
}
2290-
22912285
if (node.index && each_node_meta.contains_group_binding) {
22922286
// We needed to create a unique identifier for the index above, but we want to use the
22932287
// original index name in the template, therefore create another binding
22942288
declarations.push(b.let(node.index, index));
22952289
}
22962290

22972291
if ((each_type & EACH_KEYED) !== 0) {
2292+
if (context.state.options.dev && key_function.type !== 'Literal') {
2293+
context.state.init.push(
2294+
b.stmt(b.call('$.validate_each_keys', b.thunk(collection), key_function))
2295+
);
2296+
}
2297+
22982298
context.state.after_update.push(
22992299
b.stmt(
23002300
b.call(
@@ -2494,7 +2494,7 @@ export const template_visitors = {
24942494
next();
24952495
},
24962496
BindDirective(node, context) {
2497-
const { state, path } = context;
2497+
const { state, path, visit } = context;
24982498

24992499
/** @type {import('estree').Expression[]} */
25002500
const properties = [];
@@ -2635,7 +2635,6 @@ export const template_visitors = {
26352635
)
26362636
);
26372637
break;
2638-
26392638
case 'textContent':
26402639
case 'innerHTML':
26412640
case 'innerText':

packages/svelte/src/compiler/phases/scope.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,10 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
495495
}
496496

497497
if (node.index) {
498-
scope.declare(
499-
b.id(node.index),
500-
// TODO see logic in EachBlock in dom.ts
501-
node.key ? 'derived' : 'normal',
502-
'const'
503-
);
498+
const is_keyed =
499+
node.key &&
500+
(node.key.type !== 'Identifier' || !node.index || node.key.name !== node.index);
501+
scope.declare(b.id(node.index), is_keyed ? 'derived' : 'normal', 'const');
504502
}
505503
if (node.key) visit(node.key, { scope });
506504

packages/svelte/src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
* https://svelte.dev/docs/svelte-compiler#svelte-version
77
* @type {string}
88
*/
9-
export const VERSION = '5.0.0-next.11';
9+
export const VERSION = '5.0.0-next.12';
1010
export const PUBLIC_VERSION = '5';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
html: '<div>0</div><div>1</div>'
5+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{#each ["a", "b"] as result, i (i)}
2+
<div>{i}</div>
3+
{/each}

0 commit comments

Comments
 (0)