From 634a0734c429850a4679b2f220b14a896536a7fb Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 21 Jun 2016 03:03:49 -0400 Subject: [PATCH] support sync watcher as internal flag --- build/karma.cover.config.js | 3 ++- src/core/observer/watcher.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build/karma.cover.config.js b/build/karma.cover.config.js index 950f40a1c..c03003570 100644 --- a/build/karma.cover.config.js +++ b/build/karma.cover.config.js @@ -19,7 +19,8 @@ module.exports = function (config) { ignore: [ 'test/', 'src/compiler/parser/html-parser.js', - 'src/core/instance/proxy.js' + 'src/core/instance/proxy.js', + 'src/sfc/deindent.js' ] }]] } diff --git a/src/core/observer/watcher.js b/src/core/observer/watcher.js index 6c649e76a..95c7e7c97 100644 --- a/src/core/observer/watcher.js +++ b/src/core/observer/watcher.js @@ -27,6 +27,7 @@ export default class Watcher { deep: boolean; user: boolean; lazy: boolean; + sync: boolean; dirty: boolean; active: boolean; deps: Array; @@ -48,6 +49,7 @@ export default class Watcher { this.deep = !!options.deep this.user = !!options.user this.lazy = !!options.lazy + this.sync = !!options.sync this.expression = expOrFn.toString() this.cb = cb this.id = ++uid // uid for batching @@ -167,8 +169,11 @@ export default class Watcher { * Will be called when a dependency changes. */ update () { + /* istanbul ignore else */ if (this.lazy) { this.dirty = true + } else if (this.sync) { + this.run() } else { queueWatcher(this) }