mirror of https://github.com/sveltejs/svelte
fix else-block update in keyed each-block (#4558)
Co-authored-by: Benjamin W. Broersma <bw@broersma.com>pull/4564/head
parent
ec3589e314
commit
404ed3dbfe
@ -0,0 +1,37 @@
|
||||
export default {
|
||||
props: {
|
||||
animals: ['alpaca', 'baboon', 'capybara'],
|
||||
foo: 'something else'
|
||||
},
|
||||
|
||||
html: `
|
||||
before
|
||||
<p>alpaca</p>
|
||||
<p>baboon</p>
|
||||
<p>capybara</p>
|
||||
after
|
||||
`,
|
||||
|
||||
test({ assert, component, target }) {
|
||||
component.animals = [];
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
before
|
||||
<p>no animals, but rather something else</p>
|
||||
after
|
||||
`);
|
||||
|
||||
component.foo = 'something other';
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
before
|
||||
<p>no animals, but rather something other</p>
|
||||
after
|
||||
`);
|
||||
|
||||
component.animals = ['wombat'];
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
before
|
||||
<p>wombat</p>
|
||||
after
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
export let animals;
|
||||
export let foo;
|
||||
</script>
|
||||
|
||||
before
|
||||
{#each animals as animal (animal)}
|
||||
<p>{animal}</p>
|
||||
{:else}
|
||||
<p>no animals, but rather {foo}</p>
|
||||
{/each}
|
||||
after
|
@ -0,0 +1,37 @@
|
||||
export default {
|
||||
props: {
|
||||
animals: ['alpaca', 'baboon', 'capybara'],
|
||||
foo: 'something else'
|
||||
},
|
||||
|
||||
html: `
|
||||
before
|
||||
<p>alpaca</p>
|
||||
<p>baboon</p>
|
||||
<p>capybara</p>
|
||||
after
|
||||
`,
|
||||
|
||||
test({ assert, component, target }) {
|
||||
component.animals = [];
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
before
|
||||
<p>no animals, but rather something else</p>
|
||||
after
|
||||
`);
|
||||
|
||||
component.foo = 'something other';
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
before
|
||||
<p>no animals, but rather something other</p>
|
||||
after
|
||||
`);
|
||||
|
||||
component.animals = ['wombat'];
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
before
|
||||
<p>wombat</p>
|
||||
after
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
export let animals;
|
||||
export let foo;
|
||||
</script>
|
||||
|
||||
before
|
||||
{#each animals as animal}
|
||||
<p>{animal}</p>
|
||||
{:else}
|
||||
<p>no animals, but rather {foo}</p>
|
||||
{/each}
|
||||
after
|
Loading…
Reference in new issue