update simple if-blocks with complex but static conditions

pull/3478/head
Rich Harris 6 years ago
parent 334323fb8b
commit 6665a52bad

@ -493,6 +493,10 @@ export default class IfBlockWrapper extends Wrapper {
}
`);
}
} else if (dynamic) {
block.builders.update.add_block(
`if (${branch.condition}) ${name}.p(changed, ctx);`
);
}
block.builders.destroy.add_line(`${if_name}${name}.d(${detaching});`);

@ -0,0 +1,12 @@
export default {
props: {
foo: 42
},
html: '<p>42</p>',
test({ assert, component, target }) {
component.foo = 43;
assert.htmlEqual(target.innerHTML, '<p>43</p>');
}
};

@ -0,0 +1,9 @@
<script>
export let foo;
const show = () => true;
</script>
{#if show()}
<p>{foo}</p>
{/if}
Loading…
Cancel
Save