11/*
2- VueJS v0.8.0
2+ VueJS v0.8.1
33 (c) 2014 Evan You
44 License: MIT
55*/
@@ -1315,10 +1315,7 @@ CompilerProto.defineProp = function (key, binding) {
13151315CompilerProto . defineExp = function ( key , binding ) {
13161316 var getter = ExpParser . parse ( key , this )
13171317 if ( getter ) {
1318- var value = binding . isFn
1319- ? getter
1320- : { $get : getter }
1321- this . markComputed ( binding , value )
1318+ this . markComputed ( binding , getter )
13221319 this . exps . push ( binding )
13231320 }
13241321}
@@ -1329,10 +1326,8 @@ CompilerProto.defineExp = function (key, binding) {
13291326CompilerProto . defineComputed = function ( key , binding , value ) {
13301327 this . markComputed ( binding , value )
13311328 var def = {
1332- get : binding . value . $get
1333- }
1334- if ( binding . value . $set ) {
1335- def . set = binding . value . $set
1329+ get : binding . value . $get ,
1330+ set : binding . value . $set
13361331 }
13371332 Object . defineProperty ( this . vm , key , def )
13381333}
@@ -1342,15 +1337,19 @@ CompilerProto.defineComputed = function (key, binding, value) {
13421337 * so its getter/setter are bound to proper context
13431338 */
13441339CompilerProto . markComputed = function ( binding , value ) {
1345- binding . value = value
13461340 binding . isComputed = true
13471341 // bind the accessors to the vm
1348- if ( ! binding . isFn ) {
1349- binding . value = {
1350- $get : utils . bind ( value . $get , this . vm )
1342+ if ( binding . isFn ) {
1343+ binding . value = value
1344+ } else {
1345+ if ( typeof value === 'function' ) {
1346+ value = { $get : value }
13511347 }
1352- if ( value . $set ) {
1353- binding . value . $set = utils . bind ( value . $set , this . vm )
1348+ binding . value = {
1349+ $get : utils . bind ( value . $get , this . vm ) ,
1350+ $set : value . $set
1351+ ? utils . bind ( value . $set , this . vm )
1352+ : undefined
13541353 }
13551354 }
13561355 // keep track for dep parsing later
0 commit comments