(node, get_key, render_fn)
| 14 | * @returns {void} |
| 15 | */ |
| 16 | export function key(node, get_key, render_fn) { |
| 17 | if (hydrating) { |
| 18 | hydrate_next(); |
| 19 | } |
| 20 | |
| 21 | var branches = new BranchManager(node); |
| 22 | |
| 23 | var legacy = !is_runes(); |
| 24 | |
| 25 | block(() => { |
| 26 | var key = get_key(); |
| 27 | |
| 28 | // NaN !== NaN, hence we do this workaround to not trigger remounts unnecessarily |
| 29 | if (key !== key) { |
| 30 | key = /** @type {any} */ (NAN); |
| 31 | } |
| 32 | |
| 33 | // key blocks in Svelte <5 had stupid semantics |
| 34 | if (legacy && key !== null && typeof key === 'object') { |
| 35 | key = /** @type {V} */ ({}); |
| 36 | } |
| 37 | |
| 38 | branches.ensure(key, render_fn); |
| 39 | }); |
| 40 | } |
nothing calls this directly
no test coverage detected