update refs on outro

pull/1864/head
Rich Harris 7 years ago
parent 49a747f376
commit a7fe66960f

@ -676,7 +676,10 @@ export default class ElementWrapper extends Wrapper {
);
block.builders.destroy.addLine(
`if (${ref} === ${this.var}) ${ref} = null;`
`if (${ref} === ${this.var}) {
${ref} = null;
#component.$$.inject_refs(#component.$$refs);
}`
);
}

@ -344,6 +344,7 @@ export default class InlineComponentWrapper extends Wrapper {
${this.node.ref && deindent`
if (#component.$$refs.${this.node.ref.name} === ${name}) {
#component.$$refs.${this.node.ref.name} = null;
#component.$$.inject_refs(#component.$$refs);
}`}
}
}
@ -398,9 +399,14 @@ export default class InlineComponentWrapper extends Wrapper {
`);
}
block.builders.destroy.addLine(deindent`
block.builders.destroy.addBlock(deindent`
${name}.$destroy(${parentNode ? '' : 'detach'});
${this.node.ref && `if (#component.$$refs.${this.node.ref.name} === ${name}) #component.$$refs.${this.node.ref.name} = null;`}
${this.node.ref && deindent`
if (#component.$$refs.${this.node.ref.name} === ${name}) {
#component.$$refs.${this.node.ref.name} = null;
#component.$$.inject_refs(#component.$$refs);
}
`}
`);
}

@ -1,6 +1,4 @@
export default {
intro: true,
test(assert, component, target, window, raf) {
component.visible = true;
const div = target.querySelector('div');

Loading…
Cancel
Save