mirror of https://github.com/sveltejs/svelte
[fix] {:else if} value incorrectly cached (#7043)
parent
4240455e02
commit
2f0f330b76
@ -0,0 +1,46 @@
|
||||
export default {
|
||||
async test({ assert, component, target, window }) {
|
||||
const [btn1, btn2] = target.querySelectorAll('button');
|
||||
|
||||
const clickEvent = new window.MouseEvent('click');
|
||||
|
||||
await btn2.dispatchEvent(clickEvent);
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<button>Toggle foo</button>
|
||||
<button>Toggle bar</button>
|
||||
<hr>
|
||||
foo: false, bar: true
|
||||
<hr>
|
||||
bar!
|
||||
`);
|
||||
|
||||
await btn1.dispatchEvent(clickEvent);
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<button>Toggle foo</button>
|
||||
<button>Toggle bar</button>
|
||||
<hr>
|
||||
foo: true, bar: true
|
||||
<hr>
|
||||
foo!
|
||||
`);
|
||||
|
||||
await btn2.dispatchEvent(clickEvent);
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<button>Toggle foo</button>
|
||||
<button>Toggle bar</button>
|
||||
<hr>
|
||||
foo: true, bar: false
|
||||
<hr>
|
||||
foo!
|
||||
`);
|
||||
|
||||
await btn1.dispatchEvent(clickEvent);
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<button>Toggle foo</button>
|
||||
<button>Toggle bar</button>
|
||||
<hr>
|
||||
foo: false, bar: false
|
||||
<hr>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,21 @@
|
||||
<script>
|
||||
let foo = false
|
||||
let bar = [false];
|
||||
</script>
|
||||
|
||||
<button on:click={() => foo = !foo}>
|
||||
Toggle foo
|
||||
</button>
|
||||
<button on:click={() => bar[0] = !bar[0]}>
|
||||
Toggle bar
|
||||
</button>
|
||||
|
||||
<hr>
|
||||
{@html `foo: ${foo}, bar: ${bar.every(x => x)}`}
|
||||
<hr>
|
||||
|
||||
{#if foo}
|
||||
foo!
|
||||
{:else if bar.every(x => x)}
|
||||
bar!
|
||||
{/if}
|
Loading…
Reference in new issue