[fix] run else-if reactive function on re-renders (#6727)

pull/6744/head
Bjorn Lu 3 years ago committed by GitHub
parent 88204355d3
commit 79df74b087
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -391,7 +391,7 @@ export default class IfBlockWrapper extends Wrapper {
? b`
${snippet && (
dependencies.length > 0
? b`if (${block.renderer.dirty(dependencies)}) ${condition} = !!${snippet}`
? b`if (${condition} == null || ${block.renderer.dirty(dependencies)}) ${condition} = !!${snippet}`
: b`if (${condition} == null) ${condition} = !!${snippet}`
)}
if (${condition}) return ${i};`

@ -0,0 +1,12 @@
export default {
props: {
foo: true
},
html: 'foo',
test({ assert, component, target }) {
component.foo = false;
assert.htmlEqual(target.innerHTML, 'bar');
}
};

@ -0,0 +1,13 @@
<script>
import Foo from './Foo.svelte'
export let foo = true
$: bar = () => true
</script>
{#if foo}
<Foo />
{:else if bar()}
bar
{:else}
else
{/if}
Loading…
Cancel
Save