pull/4699/head
Conduitry 6 years ago
parent a0d86dcfe3
commit bbb676af28

@ -521,21 +521,21 @@ export default class IfBlockWrapper extends Wrapper {
const update_mount_node = this.get_update_mount_node(anchor); const update_mount_node = this.get_update_mount_node(anchor);
const enter = b` const enter = b`
if (!${name}) { if (${name}) {
${name} = ${branch.block.name}(#ctx); ${dynamic && b`${name}.p(#ctx, #dirty);`}
${name}.c(); ${
${has_transitions && b`@transition_in(${name}, 1);`} has_transitions &&
${name}.m(${update_mount_node}, ${anchor}); b`if (${block.renderer.dirty(branch.dependencies)}) {
} else {
${dynamic && b`${name}.p(#ctx, #dirty);`}
${
has_transitions &&
b`if (${block.renderer.dirty(branch.dependencies)}) {
@transition_in(${name}, 1); @transition_in(${name}, 1);
}` }`
}
} }
`; } else {
${name} = ${branch.block.name}(#ctx);
${name}.c();
${has_transitions && b`@transition_in(${name}, 1);`}
${name}.m(${update_mount_node}, ${anchor});
}
`;
if (branch.snippet) { if (branch.snippet) {
block.chunks.update.push(b`if (${block.renderer.dirty(branch.dependencies)}) ${branch.condition} = ${branch.snippet}`); block.chunks.update.push(b`if (${block.renderer.dirty(branch.dependencies)}) ${branch.condition} = ${branch.snippet}`);

@ -1,18 +1,18 @@
<script> <script>
export let condition; export let condition;
function foo(node, params) { function foo(node, params) {
return { return {
duration: 100, duration: 100,
tick: t => { tick: t => {
node.foo = t; node.foo = t;
} }
}; };
} }
let bool = true; let bool = true;
</script> </script>
<button on:click={() => (condition = false)} /> <button on:click={() => (condition = false)} />
<button on:click={() => (bool = !bool)} /> <button on:click={() => (bool = !bool)} />
{#if bool} {#if bool}
<div out:foo /> <div out:foo />
{/if} {/if}

@ -1,8 +1,8 @@
<script> <script>
import Component from "./Component.svelte"; import Component from "./Component.svelte";
let condition = true; let condition = true;
</script> </script>
{#if condition} {#if condition}
<Component bind:condition /> <Component bind:condition />
{/if} {/if}

@ -1,18 +1,18 @@
<script> <script>
export let condition; export let condition;
function foo(node, params) { function foo(node, params) {
return { return {
duration: 100, duration: 100,
tick: t => { tick: t => {
node.foo = t; node.foo = t;
} }
}; };
} }
$condition; $condition;
let bool = true; let bool = true;
</script> </script>
<button on:click={() => (bool = !bool)} /> <button on:click={() => (bool = !bool)} />
{#if bool} {#if bool}
<div out:foo /> <div out:foo />
{/if} {/if}

@ -1,10 +1,10 @@
<script> <script>
import { writable } from "svelte/store"; import { writable } from "svelte/store";
import Component from "./Component.svelte"; import Component from "./Component.svelte";
export let condition = writable(true); export let condition = writable(true);
</script> </script>
{#if $condition} {#if $condition}
<button on:click={() => ($condition = false)} id="1" /> <button on:click={() => ($condition = false)} id="1" />
<Component {condition} /> <Component {condition} />
{/if} {/if}

Loading…
Cancel
Save