refactor: immutable -> readonly

This commit is contained in:
Evan You
2019-08-23 09:38:32 -04:00
parent e1bbfbba94
commit 589d3c2feb
8 changed files with 137 additions and 137 deletions

View File

@@ -4,10 +4,10 @@ export {
toRefs,
reactive,
isReactive,
immutable,
isImmutable,
readonly,
isReadonly,
toRaw,
markImmutable,
markReadonly,
markNonReactive,
effect,
// types

View File

@@ -1,5 +1,5 @@
import { VNode, normalizeVNode, VNodeChild } from './vnode'
import { ReactiveEffect, UnwrapRef, reactive, immutable } from '@vue/reactivity'
import { ReactiveEffect, UnwrapRef, reactive, readonly } from '@vue/reactivity'
import { EMPTY_OBJ, isFunction, capitalize, invokeHandlers } from '@vue/shared'
import { RenderProxyHandlers } from './componentProxy'
import { ComponentPropsOptions, ExtractPropTypes } from './componentProps'
@@ -233,7 +233,7 @@ export function setupStatefulComponent(instance: ComponentInstance) {
// so props change can be tracked by watchers
// it will be updated in resolveProps() on updates before render
const propsProxy = (instance.propsProxy = setup.length
? immutable(instance.props)
? readonly(instance.props)
: null)
const setupContext = (instance.setupContext =
setup.length > 1 ? createSetupContext(instance) : null)

View File

@@ -1,4 +1,4 @@
import { immutable, toRaw, lock, unlock } from '@vue/reactivity'
import { readonly, toRaw, lock, unlock } from '@vue/reactivity'
import {
EMPTY_OBJ,
camelize,
@@ -114,7 +114,7 @@ export function resolveProps(
props[key] = val
}
// allow mutation of propsProxy (which is immutable by default)
// allow mutation of propsProxy (which is readonly by default)
unlock()
if (rawProps != null) {
@@ -179,13 +179,13 @@ export function resolveProps(
}
}
// lock immutable
// lock readonly
lock()
instance.props = __DEV__ ? immutable(props) : props
instance.props = __DEV__ ? readonly(props) : props
instance.attrs = options
? __DEV__
? immutable(attrs)
? readonly(attrs)
: attrs
: instance.props
}