File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 11/* @flow */
22
3- import { remove } from 'shared/util'
3+ import { remove , isDef } from 'shared/util'
44
55export default {
66 create ( _ : any , vnode : VNodeWithData ) {
@@ -19,7 +19,7 @@ export default {
1919
2020export function registerRef ( vnode : VNodeWithData , isRemoval : ?boolean ) {
2121 const key = vnode . data . ref
22- if ( ! key ) return
22+ if ( ! isDef ( key ) ) return
2323
2424 const vm = vnode . context
2525 const ref = vnode . componentInstance || vnode . elm
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ describe('ref', () => {
99 test2 : {
1010 id : 'test2' ,
1111 template : '<div>test2</div>'
12+ } ,
13+ test3 : {
14+ id : 'test3' ,
15+ template : '<div>test3</div>'
1216 }
1317 }
1418
@@ -20,6 +24,7 @@ describe('ref', () => {
2024 template : `<div>
2125 <test ref="foo"></test>
2226 <test2 :ref="value"></test2>
27+ <test3 :ref="0"></test3>
2328 </div>` ,
2429 components
2530 } )
@@ -28,6 +33,8 @@ describe('ref', () => {
2833 expect ( vm . $refs . foo . $options . id ) . toBe ( 'test' )
2934 expect ( vm . $refs . bar ) . toBeTruthy ( )
3035 expect ( vm . $refs . bar . $options . id ) . toBe ( 'test2' )
36+ expect ( vm . $refs [ '0' ] ) . toBeTruthy ( )
37+ expect ( vm . $refs [ '0' ] . $options . id ) . toBe ( 'test3' )
3138 } )
3239
3340 it ( 'should dynamically update refs' , done => {
You can’t perform that action at this time.
0 commit comments