mirror of https://github.com/sveltejs/svelte
ensure if_block dependency is dirty to cancel outro (#4634)
parent
2bf8fc7e6b
commit
8d8db4e836
@ -0,0 +1,18 @@
|
||||
<script>
|
||||
export let condition;
|
||||
function foo(node, params) {
|
||||
return {
|
||||
duration: 100,
|
||||
tick: t => {
|
||||
node.foo = t;
|
||||
}
|
||||
};
|
||||
}
|
||||
let bool = true;
|
||||
</script>
|
||||
|
||||
<button on:click={() => (condition = false)} />
|
||||
<button on:click={() => (bool = !bool)} />
|
||||
{#if bool}
|
||||
<div out:foo />
|
||||
{/if}
|
@ -0,0 +1,9 @@
|
||||
export default {
|
||||
async test({ assert, target, window, raf }) {
|
||||
const button = target.querySelector("button");
|
||||
const event = new window.MouseEvent("click");
|
||||
await button.dispatchEvent(event);
|
||||
raf.tick(500);
|
||||
assert.htmlEqual(target.innerHTML, "");
|
||||
},
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
import Component from "./Component.svelte";
|
||||
let condition = true;
|
||||
</script>
|
||||
|
||||
{#if condition}
|
||||
<Component bind:condition />
|
||||
{/if}
|
@ -0,0 +1,18 @@
|
||||
<script>
|
||||
export let condition;
|
||||
function foo(node, params) {
|
||||
return {
|
||||
duration: 100,
|
||||
tick: t => {
|
||||
node.foo = t;
|
||||
}
|
||||
};
|
||||
}
|
||||
$condition;
|
||||
let bool = true;
|
||||
</script>
|
||||
|
||||
<button on:click={() => (bool = !bool)} />
|
||||
{#if bool}
|
||||
<div out:foo />
|
||||
{/if}
|
@ -0,0 +1,7 @@
|
||||
export default {
|
||||
async test({ assert, target, component, raf }) {
|
||||
await component.condition.set(false);
|
||||
raf.tick(500);
|
||||
assert.htmlEqual(target.innerHTML, "");
|
||||
},
|
||||
};
|
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
import { writable } from "svelte/store";
|
||||
import Component from "./Component.svelte";
|
||||
export let condition = writable(true);
|
||||
</script>
|
||||
|
||||
{#if $condition}
|
||||
<button on:click={() => ($condition = false)} id="1" />
|
||||
<Component {condition} />
|
||||
{/if}
|
Loading…
Reference in new issue