@@ -517,10 +517,7 @@ CompilerProto.defineProp = function (key, binding) {
517
517
CompilerProto . defineExp = function ( key , binding ) {
518
518
var getter = ExpParser . parse ( key , this )
519
519
if ( getter ) {
520
- var value = binding . isFn
521
- ? getter
522
- : { $get : getter }
523
- this . markComputed ( binding , value )
520
+ this . markComputed ( binding , getter )
524
521
this . exps . push ( binding )
525
522
}
526
523
}
@@ -531,10 +528,8 @@ CompilerProto.defineExp = function (key, binding) {
531
528
CompilerProto . defineComputed = function ( key , binding , value ) {
532
529
this . markComputed ( binding , value )
533
530
var def = {
534
- get : binding . value . $get
535
- }
536
- if ( binding . value . $set ) {
537
- def . set = binding . value . $set
531
+ get : binding . value . $get ,
532
+ set : binding . value . $set
538
533
}
539
534
Object . defineProperty ( this . vm , key , def )
540
535
}
@@ -544,15 +539,19 @@ CompilerProto.defineComputed = function (key, binding, value) {
544
539
* so its getter/setter are bound to proper context
545
540
*/
546
541
CompilerProto . markComputed = function ( binding , value ) {
547
- binding . value = value
548
542
binding . isComputed = true
549
543
// bind the accessors to the vm
550
- if ( ! binding . isFn ) {
551
- binding . value = {
552
- $get : utils . bind ( value . $get , this . vm )
544
+ if ( binding . isFn ) {
545
+ binding . value = value
546
+ } else {
547
+ if ( typeof value === 'function' ) {
548
+ value = { $get : value }
553
549
}
554
- if ( value . $set ) {
555
- binding . value . $set = utils . bind ( value . $set , this . vm )
550
+ binding . value = {
551
+ $get : utils . bind ( value . $get , this . vm ) ,
552
+ $set : value . $set
553
+ ? utils . bind ( value . $set , this . vm )
554
+ : undefined
556
555
}
557
556
}
558
557
// keep track for dep parsing later
0 commit comments