mirror of https://github.com/sveltejs/svelte
Merge pull request #727 from sveltejs/gh-706
clear refs in destroy, not unmount, so that refs are populated in ondestroypull/733/head
commit
dbf635b445
@ -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