@@ -118,7 +118,7 @@ module.exports = {
118
118
119
119
update : function ( collection , init ) {
120
120
121
- this . unbind ( true )
121
+ this . reset ( )
122
122
// attach an object to container to hold handlers
123
123
this . container . vue_dHandlers = utils . hash ( )
124
124
// if initiating with an empty collection, we need to
@@ -173,7 +173,7 @@ module.exports = {
173
173
ctn = this . container ,
174
174
vms = this . vms ,
175
175
col = this . collection ,
176
- ref , item
176
+ ref , item , primitive
177
177
178
178
// append node into DOM first
179
179
// so v-if can get access to parentNode
@@ -188,6 +188,11 @@ module.exports = {
188
188
transition ( el , 1 , function ( ) {
189
189
ctn . insertBefore ( el , ref )
190
190
} , this . compiler )
191
+ // wrap primitive element in an object
192
+ if ( utils . typeOf ( data ) !== 'Object' ) {
193
+ primitive = true
194
+ data = { value : data }
195
+ }
191
196
}
192
197
193
198
item = new this . Ctor ( {
@@ -207,6 +212,14 @@ module.exports = {
207
212
item . $destroy ( )
208
213
} else {
209
214
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
+ }
210
223
// in case `$destroy` is called directly on a repeated vm
211
224
// make sure the vm's data is properly removed
212
225
item . $compiler . observer . on ( 'hook:afterDestroy' , function ( ) {
@@ -225,7 +238,7 @@ module.exports = {
225
238
}
226
239
} ,
227
240
228
- unbind : function ( ) {
241
+ reset : function ( ) {
229
242
if ( this . childId ) {
230
243
delete this . vm . $ [ this . childId ]
231
244
}
@@ -242,5 +255,9 @@ module.exports = {
242
255
ctn . removeEventListener ( handlers [ key ] . event , handlers [ key ] )
243
256
}
244
257
ctn . vue_dHandlers = null
258
+ } ,
259
+
260
+ unbind : function ( ) {
261
+ this . reset ( )
245
262
}
246
263
}
0 commit comments