Skip to content

Commit 634a073

Browse files
committed
support sync watcher as internal flag
1 parent 0c9c6ed commit 634a073

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

build/karma.cover.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ module.exports = function (config) {
1919
ignore: [
2020
'test/',
2121
'src/compiler/parser/html-parser.js',
22-
'src/core/instance/proxy.js'
22+
'src/core/instance/proxy.js',
23+
'src/sfc/deindent.js'
2324
]
2425
}]]
2526
}

src/core/observer/watcher.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default class Watcher {
2727
deep: boolean;
2828
user: boolean;
2929
lazy: boolean;
30+
sync: boolean;
3031
dirty: boolean;
3132
active: boolean;
3233
deps: Array<Dep>;
@@ -48,6 +49,7 @@ export default class Watcher {
4849
this.deep = !!options.deep
4950
this.user = !!options.user
5051
this.lazy = !!options.lazy
52+
this.sync = !!options.sync
5153
this.expression = expOrFn.toString()
5254
this.cb = cb
5355
this.id = ++uid // uid for batching
@@ -167,8 +169,11 @@ export default class Watcher {
167169
* Will be called when a dependency changes.
168170
*/
169171
update () {
172+
/* istanbul ignore else */
170173
if (this.lazy) {
171174
this.dirty = true
175+
} else if (this.sync) {
176+
this.run()
172177
} else {
173178
queueWatcher(this)
174179
}

0 commit comments

Comments
 (0)