Skip to content

Commit 62fd49a

Browse files
committed
do not modify original computed property getter/setters
1 parent f139f92 commit 62fd49a

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/binding.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var batcher = require('./batcher'),
2+
utils = require('./utils'),
23
id = 0
34

45
/**
@@ -28,7 +29,9 @@ var BindingProto = Binding.prototype
2829
* Update value and queue instance updates.
2930
*/
3031
BindingProto.update = function (value) {
31-
if (arguments.length) this.value = value
32+
if (!this.isComputed || this.isFn) {
33+
this.value = value
34+
}
3235
batcher.queue(this)
3336
}
3437

src/compiler.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,18 +500,17 @@ CompilerProto.define = function (key, binding) {
500500
}
501501

502502
Object.defineProperty(vm, key, {
503-
enumerable: !binding.isComputed,
504503
get: binding.isComputed
505504
? function () {
506-
return compiler.data[key].$get()
505+
return binding.value.$get()
507506
}
508507
: function () {
509508
return compiler.data[key]
510509
},
511510
set: binding.isComputed
512511
? function (val) {
513-
if (compiler.data[key].$set) {
514-
compiler.data[key].$set(val)
512+
if (binding.value.$set) {
513+
binding.value.$set(val)
515514
}
516515
}
517516
: function (val) {
@@ -529,9 +528,11 @@ CompilerProto.markComputed = function (binding) {
529528
binding.isComputed = true
530529
// bind the accessors to the vm
531530
if (!binding.isFn) {
532-
value.$get = utils.bind(value.$get, vm)
531+
binding.value = {
532+
$get: utils.bind(value.$get, vm)
533+
}
533534
if (value.$set) {
534-
value.$set = utils.bind(value.$set, vm)
535+
binding.value.$set = utils.bind(value.$set, vm)
535536
}
536537
}
537538
// keep track for dep parsing later

0 commit comments

Comments
 (0)