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 enter = b`
if (!${name}) {
${name} = ${branch.block.name}(#ctx);
${name}.c();
${has_transitions && b`@transition_in(${name}, 1);`}
${name}.m(${update_mount_node}, ${anchor});
} else {
${dynamic && b`${name}.p(#ctx, #dirty);`}
${
has_transitions &&
b`if (${block.renderer.dirty(branch.dependencies)}) {
if (${name}) {
${dynamic && b`${name}.p(#ctx, #dirty);`}
${
has_transitions &&
b`if (${block.renderer.dirty(branch.dependencies)}) {
@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) {
block.chunks.update.push(b`if (${block.renderer.dirty(branch.dependencies)}) ${branch.condition} = ${branch.snippet}`);

@ -1,18 +1,18 @@
<script>
export let condition;
function foo(node, params) {
return {
duration: 100,
tick: t => {
node.foo = t;
}
};
}
let bool = true;
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 />
<div out:foo />
{/if}

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

@ -1,18 +1,18 @@
<script>
export let condition;
function foo(node, params) {
return {
duration: 100,
tick: t => {
node.foo = t;
}
};
}
$condition;
let bool = true;
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 />
<div out:foo />
{/if}

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

Loading…
Cancel
Save