1
1
/*
2
- VueJS v0.8.0
2
+ VueJS v0.8.1
3
3
(c) 2014 Evan You
4
4
License: MIT
5
5
*/
@@ -1315,10 +1315,7 @@ CompilerProto.defineProp = function (key, binding) {
1315
1315
CompilerProto . defineExp = function ( key , binding ) {
1316
1316
var getter = ExpParser . parse ( key , this )
1317
1317
if ( getter ) {
1318
- var value = binding . isFn
1319
- ? getter
1320
- : { $get : getter }
1321
- this . markComputed ( binding , value )
1318
+ this . markComputed ( binding , getter )
1322
1319
this . exps . push ( binding )
1323
1320
}
1324
1321
}
@@ -1329,10 +1326,8 @@ CompilerProto.defineExp = function (key, binding) {
1329
1326
CompilerProto . defineComputed = function ( key , binding , value ) {
1330
1327
this . markComputed ( binding , value )
1331
1328
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
1336
1331
}
1337
1332
Object . defineProperty ( this . vm , key , def )
1338
1333
}
@@ -1342,15 +1337,19 @@ CompilerProto.defineComputed = function (key, binding, value) {
1342
1337
* so its getter/setter are bound to proper context
1343
1338
*/
1344
1339
CompilerProto . markComputed = function ( binding , value ) {
1345
- binding . value = value
1346
1340
binding . isComputed = true
1347
1341
// 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 }
1351
1347
}
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
1354
1353
}
1355
1354
}
1356
1355
// keep track for dep parsing later
0 commit comments