File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -195,11 +195,11 @@ exports._initComputed = function () {
195
195
configurable : true
196
196
}
197
197
if ( typeof userDef === 'function' ) {
198
- def . get = _ . bind ( userDef , this )
198
+ def . get = makeComputedGetter ( userDef , this )
199
199
def . set = noop
200
200
} else {
201
201
def . get = userDef . get
202
- ? userDef . cache
202
+ ? userDef . cache !== false
203
203
? makeComputedGetter ( userDef . get , this )
204
204
: _ . bind ( userDef . get , this )
205
205
: noop
Original file line number Diff line number Diff line change @@ -180,7 +180,6 @@ describe('Instance Scope', function () {
180
180
} ,
181
181
// cached
182
182
f : {
183
- cache : true ,
184
183
get : function ( ) {
185
184
spyF ( )
186
185
return this . ff
@@ -192,7 +191,6 @@ describe('Instance Scope', function () {
192
191
} ,
193
192
// another cached, for watcher test
194
193
h : {
195
- cache : true ,
196
194
get : function ( ) {
197
195
return this . hh
198
196
}
@@ -305,6 +303,26 @@ describe('Instance Scope', function () {
305
303
expect ( vm . e ) . toBe ( 'CDe' )
306
304
} )
307
305
306
+ it ( 'disable cache' , function ( ) {
307
+ var external = { b : 'B' }
308
+ var vm = new Vue ( {
309
+ data : {
310
+ a : 'A'
311
+ } ,
312
+ computed : {
313
+ test : {
314
+ cache : false ,
315
+ get : function ( ) {
316
+ return this . a + external . b
317
+ }
318
+ }
319
+ }
320
+ } )
321
+ expect ( vm . test ) . toBe ( 'AB' )
322
+ external . b = 'C'
323
+ expect ( vm . test ) . toBe ( 'AC' )
324
+ } )
325
+
308
326
} )
309
327
310
328
describe ( 'methods' , function ( ) {
You can’t perform that action at this time.
0 commit comments