Skip to content

Commit 3cd1b53

Browse files
committed
cache computed by default (regression in #1232)
1 parent 3a45796 commit 3cd1b53

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

src/deprecations.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,6 @@ if (process.env.NODE_ENV !== 'production') {
144144
)
145145
},
146146

147-
COMPUTED_CACHE: function (name) {
148-
warn(
149-
'Computed property "' + name + '": computed properties are not cached by ' +
150-
'default in 1.0.0. You only need to enable cache for particularly expensive ones.'
151-
)
152-
},
153-
154147
BIND_IS: function () {
155148
warn(
156149
'<component is="{{view}}"> syntax will be deprecated in 1.0.0. Use ' +

src/instance/state.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,11 @@ exports._initComputed = function () {
199199
configurable: true
200200
}
201201
if (typeof userDef === 'function') {
202-
def.get = _.bind(userDef, this)
202+
def.get = makeComputedGetter(userDef, this)
203203
def.set = noop
204204
} else {
205-
206-
if (process.env.NODE_ENV !== 'production' && userDef.cache === false) {
207-
_.deprecation.COMPUTED_CACHE(key)
208-
}
209-
210205
def.get = userDef.get
211-
? userDef.cache
206+
? userDef.cache !== false
212207
? makeComputedGetter(userDef.get, this)
213208
: _.bind(userDef.get, this)
214209
: noop

test/unit/specs/instance/state_spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,15 @@ describe('Instance state initialization', function () {
161161

162162
var Test = Vue.extend({
163163
computed: {
164-
c: function () {
165-
return this.a + this.b
164+
// uncached
165+
c: {
166+
cache: false,
167+
get: function () {
168+
return this.a + this.b
169+
}
166170
},
171+
// with setter
167172
d: {
168-
cache: false, // for deprecation coverage. TODO: remove in 1.0.0
169173
get: function () {
170174
return this.a + this.b
171175
},
@@ -181,7 +185,6 @@ describe('Instance state initialization', function () {
181185
},
182186
// cached
183187
f: {
184-
cache: true,
185188
get: function () {
186189
spyF()
187190
return this.ff
@@ -193,7 +196,6 @@ describe('Instance state initialization', function () {
193196
},
194197
// another cached, for watcher test
195198
h: {
196-
cache: true,
197199
get: function () {
198200
return this.hh
199201
}

0 commit comments

Comments
 (0)