@@ -55,8 +55,8 @@ module.exports = {
5555 // check v-ref
5656 var ref = this . param ( config . prefix + 'ref' )
5757 /* istanbul ignore if */
58- if ( process . env . NODE_ENV !== 'production' ) {
59- if ( this . refID ) _ . deprecation . V_REF ( )
58+ if ( process . env . NODE_ENV !== 'production' && ref ) {
59+ _ . deprecation . V_REF ( )
6060 }
6161 this . ref = ref || this . param ( 'ref' )
6262
@@ -206,6 +206,8 @@ module.exports = {
206206 // create iteration scope
207207 var parentScope = this . _scope || this . vm
208208 var scope = Object . create ( parentScope )
209+ // ref holder for the scope
210+ scope . $ = { }
209211 // make sure point $parent to parent scope
210212 scope . $parent = parentScope
211213 // for two-way binding on alias
@@ -230,14 +232,22 @@ module.exports = {
230232 */
231233
232234 updateRef : function ( ) {
235+ var ref = this . ref
236+ var hash = ( this . _scope || this . vm ) . $
237+ var refs
233238 if ( ! this . converted ) {
234- this . vm . $ [ this . ref ] = this . frags . map ( findVmFromFrag )
239+ refs = this . frags . map ( findVmFromFrag )
235240 } else {
236- var refs = this . vm . $ [ this . ref ] = { }
241+ refs = { }
237242 this . frags . forEach ( function ( frag ) {
238243 refs [ frag . scope . $key ] = findVmFromFrag ( frag )
239244 } )
240245 }
246+ if ( ! hash . hasOwnProperty ( ref ) ) {
247+ _ . defineReactive ( hash , ref , refs )
248+ } else {
249+ hash [ ref ] = refs
250+ }
241251 } ,
242252
243253 /**
@@ -480,7 +490,7 @@ module.exports = {
480490
481491 unbind : function ( ) {
482492 if ( this . ref ) {
483- this . vm . $ [ this . ref ] = null
493+ ( this . _scope || this . vm ) . $ [ this . ref ] = null
484494 }
485495 if ( this . frags ) {
486496 var i = this . frags . length
0 commit comments