mirror of https://github.com/sveltejs/svelte
fix: properly remove root anchor node on unmount (#13381)
parent
0f6cc2b1ed
commit
0b3fd4e42d
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: properly remove root anchor node on unmount
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
let { text = 'hello' } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>{text}</p>
|
@ -0,0 +1,23 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
test({ assert, target }) {
|
||||||
|
const btn = target.querySelector('button');
|
||||||
|
btn?.click();
|
||||||
|
flushSync();
|
||||||
|
btn?.click();
|
||||||
|
flushSync();
|
||||||
|
btn?.click();
|
||||||
|
flushSync();
|
||||||
|
btn?.click();
|
||||||
|
flushSync();
|
||||||
|
btn?.click();
|
||||||
|
flushSync();
|
||||||
|
|
||||||
|
const div = target.querySelector('div');
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, '<button>generate</button><div></div>');
|
||||||
|
assert.equal(div?.childNodes.length, 0);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,20 @@
|
|||||||
|
<script>
|
||||||
|
import { mount, unmount } from "svelte";
|
||||||
|
import Component from "./Component.svelte";
|
||||||
|
|
||||||
|
let target;
|
||||||
|
|
||||||
|
function generate() {
|
||||||
|
for (let i = 0; i < 1000; i++) {
|
||||||
|
let myInnocentState = $state({text: "hello"})
|
||||||
|
const toUnmount = mount(Component, {
|
||||||
|
target: target,
|
||||||
|
props: myInnocentState,
|
||||||
|
});
|
||||||
|
unmount(toUnmount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={generate}>generate</button>
|
||||||
|
<div bind:this={target}></div>
|
Loading…
Reference in new issue