Comparing version 0.8.1 to 0.8.2
{ | ||
"name": "vue", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"author": { | ||
@@ -21,2 +21,4 @@ "name": "Evan You", | ||
}, | ||
"bugs": "https://github.com/yyx990803/vue/issues", | ||
"homepage": "http://vuejs.org", | ||
"scripts": { | ||
@@ -23,0 +25,0 @@ "test": "grunt travis" |
@@ -48,2 +48,3 @@ var Emitter = require('./emitter'), | ||
compiler.dirs = [] | ||
compiler.deferred = [] | ||
compiler.exps = [] | ||
@@ -121,7 +122,10 @@ compiler.computed = [] | ||
// extract dependencies for computed properties | ||
if (compiler.computed.length) { | ||
DepsParser.parse(compiler.computed) | ||
// bind deferred directives (child components) | ||
for (var i = 0, l = compiler.deferred.length; i < l; i++) { | ||
compiler.bindDirective(compiler.deferred[i]) | ||
} | ||
// extract dependencies for computed properties | ||
compiler.parseDeps() | ||
// done! | ||
@@ -252,3 +256,6 @@ compiler.init = false | ||
directive.Ctor = componentCtor | ||
compiler.bindDirective(directive) | ||
// defer child component compilation | ||
// so by the time they are compiled, the parent | ||
// would have collected all bindings | ||
compiler.deferred.push(directive) | ||
} | ||
@@ -262,3 +269,3 @@ | ||
directive.Ctor = componentCtor | ||
compiler.bindDirective(directive) | ||
compiler.deferred.push(directive) | ||
} | ||
@@ -599,2 +606,10 @@ | ||
/** | ||
* Collect dependencies for computed properties | ||
*/ | ||
CompilerProto.parseDeps = function () { | ||
if (!this.computed.length) return | ||
DepsParser.parse(this.computed) | ||
} | ||
/** | ||
* Unbind and remove element | ||
@@ -601,0 +616,0 @@ */ |
@@ -14,2 +14,3 @@ var Emitter = require('./emitter'), | ||
var got = utils.hash() | ||
binding.deps = [] | ||
catcher.on('get', function (dep) { | ||
@@ -40,3 +41,4 @@ var has = got[dep.key] | ||
Observer.shouldGet = true | ||
bindings.forEach(catchDeps) | ||
var i = bindings.length | ||
while (i--) { catchDeps(bindings[i]) } | ||
Observer.shouldGet = false | ||
@@ -43,0 +45,0 @@ utils.log('\ndone.') |
@@ -113,2 +113,5 @@ var Observer = require('../observer'), | ||
} | ||
if (method === 'push' || method === 'unshift' || method === 'splice') { | ||
self.changed() | ||
} | ||
} | ||
@@ -118,16 +121,17 @@ | ||
update: function (collection) { | ||
update: function (collection, init) { | ||
this.unbind(true) | ||
var self = this | ||
self.unbind(true) | ||
// attach an object to container to hold handlers | ||
this.container.vue_dHandlers = utils.hash() | ||
self.container.vue_dHandlers = utils.hash() | ||
// if initiating with an empty collection, we need to | ||
// force a compile so that we get all the bindings for | ||
// dependency extraction. | ||
if (!this.initiated && (!collection || !collection.length)) { | ||
this.buildItem() | ||
this.initiated = true | ||
if (!self.initiated && (!collection || !collection.length)) { | ||
self.buildItem() | ||
self.initiated = true | ||
} | ||
collection = this.collection = collection || [] | ||
this.vms = [] | ||
collection = self.collection = collection || [] | ||
self.vms = [] | ||
@@ -137,3 +141,3 @@ // listen for collection mutation events | ||
if (!collection.__observer__) Observer.watchArray(collection, null, new Emitter()) | ||
collection.__observer__.on('mutate', this.mutationListener) | ||
collection.__observer__.on('mutate', self.mutationListener) | ||
@@ -143,4 +147,5 @@ // create child-vms and append to DOM | ||
for (var i = 0, l = collection.length; i < l; i++) { | ||
this.buildItem(collection[i], i) | ||
self.buildItem(collection[i], i) | ||
} | ||
if (!init) self.changed() | ||
} | ||
@@ -150,2 +155,18 @@ }, | ||
/** | ||
* Notify parent compiler that new items | ||
* have been added to the collection, it needs | ||
* to re-calculate computed property dependencies. | ||
* Batched to ensure it's called only once every event loop. | ||
*/ | ||
changed: function () { | ||
var self = this | ||
if (self.queued) return | ||
self.queued = true | ||
setTimeout(function () { | ||
self.compiler.parseDeps() | ||
self.queued = false | ||
}, 0) | ||
}, | ||
/** | ||
* Create a new child VM from a data object | ||
@@ -152,0 +173,0 @@ * passing along compiler options indicating this |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
5632
1
209045
26
7
2