null out refs to dynamic components - fixes #1596

pull/1597/head
Rich Harris 7 years ago
parent 63e64c6f42
commit 87e2241928

@ -429,6 +429,8 @@ export default class Component extends Node {
`)}
${this.ref && `#component.refs.${this.ref} = ${name};`}
} else {
${name} = null;
}
${this.ref && deindent`

@ -0,0 +1,21 @@
export default {
html: `
<p>Foo</p>
`,
nestedTransitions: true,
test(assert, component, target) {
const state = component.get();
component.set({ Foo: null });
assert.htmlEqual(target.innerHTML, ``);
component.set({ Foo: state.Foo });
assert.htmlEqual(target.innerHTML, `
<p>Foo</p>
`);
}
};

@ -0,0 +1,11 @@
<svelte:component this={Foo}/>
<script>
import Foo from './Foo.html';
export default {
data() {
return { Foo };
}
};
</script>
Loading…
Cancel
Save