@@ -118,7 +118,7 @@ module.exports = {
118118
119119 update : function ( collection , init ) {
120120
121- this . unbind ( true )
121+ this . reset ( )
122122 // attach an object to container to hold handlers
123123 this . container . vue_dHandlers = utils . hash ( )
124124 // if initiating with an empty collection, we need to
@@ -173,7 +173,7 @@ module.exports = {
173173 ctn = this . container ,
174174 vms = this . vms ,
175175 col = this . collection ,
176- ref , item
176+ ref , item , primitive
177177
178178 // append node into DOM first
179179 // so v-if can get access to parentNode
@@ -188,6 +188,11 @@ module.exports = {
188188 transition ( el , 1 , function ( ) {
189189 ctn . insertBefore ( el , ref )
190190 } , this . compiler )
191+ // wrap primitive element in an object
192+ if ( utils . typeOf ( data ) !== 'Object' ) {
193+ primitive = true
194+ data = { value : data }
195+ }
191196 }
192197
193198 item = new this . Ctor ( {
@@ -207,6 +212,14 @@ module.exports = {
207212 item . $destroy ( )
208213 } else {
209214 vms . splice ( index , 0 , item )
215+ // for primitive values, listen for value change
216+ if ( primitive ) {
217+ data . __observer__ . on ( 'set' , function ( key , val ) {
218+ if ( key === 'value' ) {
219+ col [ item . $index ] = val
220+ }
221+ } )
222+ }
210223 // in case `$destroy` is called directly on a repeated vm
211224 // make sure the vm's data is properly removed
212225 item . $compiler . observer . on ( 'hook:afterDestroy' , function ( ) {
@@ -225,7 +238,7 @@ module.exports = {
225238 }
226239 } ,
227240
228- unbind : function ( ) {
241+ reset : function ( ) {
229242 if ( this . childId ) {
230243 delete this . vm . $ [ this . childId ]
231244 }
@@ -242,5 +255,9 @@ module.exports = {
242255 ctn . removeEventListener ( handlers [ key ] . event , handlers [ key ] )
243256 }
244257 ctn . vue_dHandlers = null
258+ } ,
259+
260+ unbind : function ( ) {
261+ this . reset ( )
245262 }
246263}
0 commit comments