From: Evan You Date: Wed, 9 Oct 2019 16:22:08 +0000 (-0400) Subject: refactor(reactivity): use NOOP for readonly computed setter in production X-Git-Tag: v3.0.0-alpha.0~535 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8f1475b8dd840962c8c170cfc5304836792c6431;p=thirdparty%2Fvuejs%2Fcore.git refactor(reactivity): use NOOP for readonly computed setter in production --- diff --git a/packages/reactivity/src/computed.ts b/packages/reactivity/src/computed.ts index b505e30157..9f2ede3675 100644 --- a/packages/reactivity/src/computed.ts +++ b/packages/reactivity/src/computed.ts @@ -1,6 +1,6 @@ import { effect, ReactiveEffect, activeReactiveEffectStack } from './effect' import { Ref, refSymbol, UnwrapNestedRefs } from './ref' -import { isFunction } from '@vue/shared' +import { isFunction, NOOP } from '@vue/shared' export interface ComputedRef extends Ref { readonly value: UnwrapNestedRefs @@ -28,11 +28,11 @@ export function computed( ? (getterOrOptions as (() => T)) : (getterOrOptions as WritableComputedOptions).get const setter = isReadonly - ? () => { - if (__DEV__) { + ? __DEV__ + ? () => { console.warn('Write operation failed: computed value is readonly') } - } + : NOOP : (getterOrOptions as WritableComputedOptions).set let dirty = true