Skip to content

Commit 2248960

Browse files
author
Evan You
committed
allow $watch on $data
1 parent 4d22363 commit 2248960

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/compiler.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ CompilerProto.observeData = function (data) {
312312
compiler.data = newData
313313
Observer.copyPaths(newData, oldData)
314314
Observer.observe(newData, '', observer)
315-
compiler.observer.emit('set', '$data', newData)
315+
update()
316316
}
317317
})
318318

@@ -322,9 +322,12 @@ CompilerProto.observeData = function (data) {
322322
.on('mutate', onSet)
323323

324324
function onSet (key) {
325-
if (key !== '$data') {
326-
$dataBinding.update(compiler.data)
327-
}
325+
if (key !== '$data') update()
326+
}
327+
328+
function update () {
329+
$dataBinding.update(compiler.data)
330+
observer.emit('change:$data', compiler.data)
328331
}
329332
}
330333

0 commit comments

Comments
 (0)