fix nested block not reactive (#4294)

pull/4303/head
Tan Li Hau 5 years ago committed by Conduitry
parent e93c991362
commit e4daaccd06

@ -1,5 +1,9 @@
# Svelte changelog
## Unreleased
* Fix updating a `<slot>` inside an `{#if}` or other block ([#4292](https://github.com/sveltejs/svelte/issues/4292))
## 3.17.2
* Fix removing attributes during hydration ([#1733](https://github.com/sveltejs/svelte/issues/1733))

@ -160,6 +160,9 @@ export default class Block {
});
this.has_update_method = true;
if (this.parent) {
this.parent.add_dependencies(dependencies);
}
}
add_element(

@ -0,0 +1,6 @@
<script>
let val;
</script>
<input bind:value={val} />
<slot {val}></slot>

@ -0,0 +1,30 @@
export default {
html: `
<input>
`,
async test({ assert, target, snapshot, component, window }) {
const input = target.querySelector('input');
input.value = 'a';
await input.dispatchEvent(new window.Event('input'));
assert.htmlEqual(
target.innerHTML,
`
<input>
Display: a
`
);
input.value = 'abc';
await input.dispatchEvent(new window.Event('input'));
assert.htmlEqual(
target.innerHTML,
`
<input>
Display: abc
`
);
},
};

@ -0,0 +1,10 @@
<script>
import Input from "./Input.svelte";
import Display from "./Display.svelte";
</script>
<Input let:val={foo}>
{#if foo}
<Display>{foo}</Display>
{/if}
</Input>
Loading…
Cancel
Save