@@ -517,10 +517,7 @@ CompilerProto.defineProp = function (key, binding) {
517517CompilerProto . defineExp = function ( key , binding ) {
518518 var getter = ExpParser . parse ( key , this )
519519 if ( getter ) {
520- var value = binding . isFn
521- ? getter
522- : { $get : getter }
523- this . markComputed ( binding , value )
520+ this . markComputed ( binding , getter )
524521 this . exps . push ( binding )
525522 }
526523}
@@ -531,10 +528,8 @@ CompilerProto.defineExp = function (key, binding) {
531528CompilerProto . defineComputed = function ( key , binding , value ) {
532529 this . markComputed ( binding , value )
533530 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
538533 }
539534 Object . defineProperty ( this . vm , key , def )
540535}
@@ -544,15 +539,19 @@ CompilerProto.defineComputed = function (key, binding, value) {
544539 * so its getter/setter are bound to proper context
545540 */
546541CompilerProto . markComputed = function ( binding , value ) {
547- binding . value = value
548542 binding . isComputed = true
549543 // 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 }
553549 }
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
556555 }
557556 }
558557 // keep track for dep parsing later
0 commit comments