mirror of https://github.com/sveltejs/svelte
[fix] add key dependencies into block dependencies (#7422)
* add key dependencies into block dependencies * fix lintpull/7286/head
parent
6ef0aa2944
commit
89fda7edae
@ -0,0 +1 @@
|
||||
<slot/>
|
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
import { onMount } from "svelte";
|
||||
|
||||
export let logs;
|
||||
|
||||
onMount(() => {
|
||||
logs.push("mount");
|
||||
return () => {
|
||||
logs.push("unmount");
|
||||
};
|
||||
});
|
||||
</script>
|
@ -0,0 +1,18 @@
|
||||
const logs = [];
|
||||
|
||||
export default {
|
||||
html: '<button>Reset!</button>',
|
||||
props: {
|
||||
logs
|
||||
},
|
||||
async test({ assert, component, target, raf }) {
|
||||
assert.deepEqual(logs, ['mount']);
|
||||
|
||||
const button = target.querySelector('button');
|
||||
|
||||
const click = new window.MouseEvent('click');
|
||||
await button.dispatchEvent(click);
|
||||
|
||||
assert.deepEqual(logs, ['mount', 'unmount', 'mount']);
|
||||
}
|
||||
};
|
@ -0,0 +1,17 @@
|
||||
<script>
|
||||
import Component1 from './Component1.svelte'
|
||||
import Component2 from './Component2.svelte'
|
||||
|
||||
let reset = false
|
||||
export let logs;
|
||||
</script>
|
||||
|
||||
<Component1>
|
||||
{#key reset}
|
||||
<Component2 {logs} />
|
||||
{/key}
|
||||
</Component1>
|
||||
|
||||
<button on:click={() => reset = !reset}>
|
||||
Reset!
|
||||
</button>
|
Loading…
Reference in new issue