Skip to content

Commit 4efcc52

Browse files
committed
move legacy logic to key block
1 parent 6aeaa38 commit 4efcc52

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

packages/svelte/src/internal/client/dom/blocks/branches.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ export class BranchManager {
3232
/** @type {Map<Key, Branch>} */
3333
#offscreen = new Map();
3434

35-
#legacy = !is_runes();
36-
3735
/**
3836
* Whether to pause (i.e. outro) on change, or destroy immediately.
3937
* This is necessary for `<svelte:element>`
@@ -137,11 +135,6 @@ export class BranchManager {
137135
var batch = /** @type {Batch} */ (current_batch);
138136
var defer = should_defer_append();
139137

140-
// key blocks in Svelte <5 had stupid semantics
141-
if (this.#legacy && key !== null && typeof key === 'object') {
142-
key = {};
143-
}
144-
145138
if (fn && !this.#onscreen.has(key) && !this.#offscreen.has(key)) {
146139
if (defer) {
147140
var fragment = document.createDocumentFragment();

packages/svelte/src/internal/client/dom/blocks/key.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/** @import { TemplateNode } from '#client' */
2+
import { is_runes } from '../../context.js';
23
import { block } from '../../reactivity/effects.js';
34
import { hydrate_next, hydrating } from '../hydration.js';
45
import { BranchManager } from './branches.js';
@@ -17,7 +18,16 @@ export function key(node, get_key, render_fn) {
1718

1819
var branches = new BranchManager(node);
1920

21+
var legacy = !is_runes();
22+
2023
block(() => {
21-
branches.ensure(get_key(), render_fn);
24+
var key = get_key();
25+
26+
// key blocks in Svelte <5 had stupid semantics
27+
if (legacy && key !== null && typeof key === 'object') {
28+
key = /** @type {V} */ ({});
29+
}
30+
31+
branches.ensure(key, render_fn);
2232
});
2333
}

0 commit comments

Comments
 (0)