mirror of https://github.com/sveltejs/svelte
fix: reset hydrate_node after `hydrate(...)` (#12512)
parent
30b143cef0
commit
f402d01454
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: reset hydrate node after `hydrate(...)`
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
let count = $state(0);
|
||||
</script>
|
||||
|
||||
<button onclick={() => (count += 1)}>
|
||||
clicks: {count}
|
||||
</button>
|
@ -0,0 +1,21 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
props: {
|
||||
browser: true
|
||||
},
|
||||
|
||||
server_props: {
|
||||
browser: false
|
||||
},
|
||||
|
||||
html: `<div><button>clicks: 0</button></div>`,
|
||||
|
||||
test({ target, assert }) {
|
||||
const button = target.querySelector('button');
|
||||
|
||||
flushSync(() => button?.click());
|
||||
assert.htmlEqual(target.innerHTML, `<div><button>clicks: 1</button></div>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,20 @@
|
||||
<script>
|
||||
import { createRawSnippet, hydrate } from 'svelte';
|
||||
import { render } from 'svelte/server';
|
||||
import Child from './Child.svelte';
|
||||
|
||||
let { browser } = $props();
|
||||
|
||||
let count = $state(0);
|
||||
|
||||
const hello = createRawSnippet((count) => ({
|
||||
render: () => `
|
||||
<div>${browser ? '' : render(Child).body}</div>
|
||||
`,
|
||||
setup(target) {
|
||||
hydrate(Child, { target })
|
||||
}
|
||||
}));
|
||||
</script>
|
||||
|
||||
{@render hello()}
|
Loading…
Reference in new issue