fix: correctly handle bindings on the server (#18009)

`item.subsume(item)` did nothing, honestly kinda weird how this only
turned up now

Fixes #17981
pull/18006/head
Simon H 3 months ago committed by GitHub
parent 957f2755fa
commit 04eadbc8a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: correctly handle bindings on the server

@ -468,10 +468,14 @@ export class Renderer {
}
this.local = other.local;
this.#out = other.#out.map((item) => {
if (item instanceof Renderer) {
item.subsume(item);
this.#out = other.#out.map((item, i) => {
const current = this.#out[i];
if (current instanceof Renderer && item instanceof Renderer) {
current.subsume(item);
return current;
}
return item;
});
this.promise = other.promise;

@ -0,0 +1,7 @@
<script>
let data = $derived(await Promise.resolve('test'));
</script>
<div data-resolved={data ? 'true' : 'false'}>
{data}
</div>

@ -0,0 +1,7 @@
<script>
import Bound from './Bound.svelte';
let open;
</script>
<Bound bind:open />

@ -0,0 +1,10 @@
import { test } from '../../test';
// Tests that renderer.subsume (which is used when bindings are present) works correctly
export default test({
mode: ['hydrate'],
html: '<div data-resolved="true">test</div>',
async test({ assert, warnings }) {
assert.deepEqual(warnings, []);
}
});

@ -0,0 +1,7 @@
<script lang="ts">
import Async from './Async.svelte';
import Binding from './Binding.svelte';
</script>
<Async />
<Binding />
Loading…
Cancel
Save