mirror of https://github.com/sveltejs/svelte
clear refs in destroy, not unmount, so that refs are populated in ondestroy. fixes #706
parent
5c4905a595
commit
4d36908525
@ -0,0 +1,9 @@
|
||||
<div ref:element></div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
ondestroy() {
|
||||
this.refOnDestroy = this.refs.element;
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,9 @@
|
||||
export default {
|
||||
test(assert, component, target) {
|
||||
const top = component.refs.top;
|
||||
const div = target.querySelector('div');
|
||||
|
||||
component.set({ visible: false });
|
||||
assert.equal(top.refOnDestroy, div);
|
||||
}
|
||||
};
|
@ -0,0 +1,18 @@
|
||||
{{#if visible}}
|
||||
<Top ref:top></Top>
|
||||
{{/if}}
|
||||
|
||||
<script>
|
||||
import Top from './Top.html';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
visible: true
|
||||
};
|
||||
},
|
||||
components: {
|
||||
Top
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue