File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
3
- import { remove } from 'shared/util'
3
+ import { remove , isDef } from 'shared/util'
4
4
5
5
export default {
6
6
create ( _ : any , vnode : VNodeWithData ) {
@@ -19,7 +19,7 @@ export default {
19
19
20
20
export function registerRef ( vnode : VNodeWithData , isRemoval : ?boolean ) {
21
21
const key = vnode . data . ref
22
- if ( ! key ) return
22
+ if ( ! isDef ( key ) ) return
23
23
24
24
const vm = vnode . context
25
25
const ref = vnode . componentInstance || vnode . elm
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ describe('ref', () => {
9
9
test2 : {
10
10
id : 'test2' ,
11
11
template : '<div>test2</div>'
12
+ } ,
13
+ test3 : {
14
+ id : 'test3' ,
15
+ template : '<div>test3</div>'
12
16
}
13
17
}
14
18
@@ -20,6 +24,7 @@ describe('ref', () => {
20
24
template : `<div>
21
25
<test ref="foo"></test>
22
26
<test2 :ref="value"></test2>
27
+ <test3 :ref="0"></test3>
23
28
</div>` ,
24
29
components
25
30
} )
@@ -28,6 +33,8 @@ describe('ref', () => {
28
33
expect ( vm . $refs . foo . $options . id ) . toBe ( 'test' )
29
34
expect ( vm . $refs . bar ) . toBeTruthy ( )
30
35
expect ( vm . $refs . bar . $options . id ) . toBe ( 'test2' )
36
+ expect ( vm . $refs [ '0' ] ) . toBeTruthy ( )
37
+ expect ( vm . $refs [ '0' ] . $options . id ) . toBe ( 'test3' )
31
38
} )
32
39
33
40
it ( 'should dynamically update refs' , done => {
You can’t perform that action at this time.
0 commit comments