File tree 4 files changed +37
-1
lines changed
src/generators/dom/visitors/Element
test/runtime/samples/ondestroy-before-cleanup
4 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export default function visitRef(
17
17
`#component.refs.${ name } = ${ state . parentNode } ;`
18
18
) ;
19
19
20
- block . builders . unmount . addLine ( deindent `
20
+ block . builders . destroy . addLine ( deindent `
21
21
if ( #component.refs.${ name } === ${ state . parentNode } ) #component.refs.${ name } = null;
22
22
` ) ;
23
23
Original file line number Diff line number Diff line change
1
+ < div ref:element > </ div >
2
+
3
+ < script >
4
+ export default {
5
+ ondestroy ( ) {
6
+ this . refOnDestroy = this . refs . element ;
7
+ }
8
+ } ;
9
+ </ script >
Original file line number Diff line number Diff line change
1
+ export default {
2
+ test ( assert , component , target ) {
3
+ const top = component . refs . top ;
4
+ const div = target . querySelector ( 'div' ) ;
5
+
6
+ component . set ( { visible : false } ) ;
7
+ assert . equal ( top . refOnDestroy , div ) ;
8
+ }
9
+ } ;
Original file line number Diff line number Diff line change
1
+ {{#if visible}}
2
+ < Top ref:top > </ Top >
3
+ {{/if}}
4
+
5
+ < script >
6
+ import Top from './Top.html' ;
7
+
8
+ export default {
9
+ data ( ) {
10
+ return {
11
+ visible : true
12
+ } ;
13
+ } ,
14
+ components : {
15
+ Top
16
+ }
17
+ } ;
18
+ </ script >
You can’t perform that action at this time.
0 commit comments