|
@@ -52,7 +52,7 @@ module.exports = {
|
|
|
el : e.currentTarget,
|
|
el : e.currentTarget,
|
|
|
originalEvent : e,
|
|
originalEvent : e,
|
|
|
directive : self,
|
|
directive : self,
|
|
|
- seed : self.seed
|
|
|
|
|
|
|
+ seed : e.currentTarget.seed
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
this.el.addEventListener(event, proxy)
|
|
this.el.addEventListener(event, proxy)
|
|
@@ -77,12 +77,8 @@ module.exports = {
|
|
|
this.childSeeds = []
|
|
this.childSeeds = []
|
|
|
},
|
|
},
|
|
|
update: function (collection) {
|
|
update: function (collection) {
|
|
|
- if (this.childSeeds.length) {
|
|
|
|
|
- this.childSeeds.forEach(function (child) {
|
|
|
|
|
- child.destroy()
|
|
|
|
|
- })
|
|
|
|
|
- this.childSeeds = []
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.unbind(true)
|
|
|
|
|
+ this.childSeeds = []
|
|
|
if (!Array.isArray(collection)) return
|
|
if (!Array.isArray(collection)) return
|
|
|
watchArray(collection, this.mutate.bind(this))
|
|
watchArray(collection, this.mutate.bind(this))
|
|
|
var self = this
|
|
var self = this
|
|
@@ -90,9 +86,6 @@ module.exports = {
|
|
|
self.childSeeds.push(self.buildItem(item, i, collection))
|
|
self.childSeeds.push(self.buildItem(item, i, collection))
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- mutate: function (mutation) {
|
|
|
|
|
- console.log(mutation)
|
|
|
|
|
- },
|
|
|
|
|
buildItem: function (data, index, collection) {
|
|
buildItem: function (data, index, collection) {
|
|
|
var Seed = require('./seed'),
|
|
var Seed = require('./seed'),
|
|
|
node = this.el.cloneNode(true)
|
|
node = this.el.cloneNode(true)
|
|
@@ -100,12 +93,22 @@ module.exports = {
|
|
|
eachPrefixRE: new RegExp('^' + this.arg + '.'),
|
|
eachPrefixRE: new RegExp('^' + this.arg + '.'),
|
|
|
parentSeed: this.seed,
|
|
parentSeed: this.seed,
|
|
|
index: index,
|
|
index: index,
|
|
|
- eachCollection: collection,
|
|
|
|
|
data: data
|
|
data: data
|
|
|
})
|
|
})
|
|
|
this.container.insertBefore(node, this.marker)
|
|
this.container.insertBefore(node, this.marker)
|
|
|
collection[index] = spore.scope
|
|
collection[index] = spore.scope
|
|
|
return spore
|
|
return spore
|
|
|
|
|
+ },
|
|
|
|
|
+ mutate: function (mutation) {
|
|
|
|
|
+ console.log(mutation)
|
|
|
|
|
+ },
|
|
|
|
|
+ unbind: function (rm) {
|
|
|
|
|
+ if (this.childSeeds.length) {
|
|
|
|
|
+ var fn = rm ? 'destroy' : 'unbind'
|
|
|
|
|
+ this.childSeeds.forEach(function (child) {
|
|
|
|
|
+ child[fn]()
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|