refactor: rename
This commit is contained in:
parent
9595446291
commit
46524a0f0f
@ -46,9 +46,9 @@ const isReservedKey = (key: string): boolean => key[0] === '_' || key[0] === '$'
|
|||||||
export function initializeProps(
|
export function initializeProps(
|
||||||
instance: ComponentInstance,
|
instance: ComponentInstance,
|
||||||
options: NormalizedPropsOptions | undefined,
|
options: NormalizedPropsOptions | undefined,
|
||||||
data: Data | null
|
rawProps: Data | null
|
||||||
) {
|
) {
|
||||||
const { 0: props, 1: attrs } = resolveProps(data, options)
|
const { 0: props, 1: attrs } = resolveProps(rawProps, options)
|
||||||
instance.$props = __DEV__ ? immutable(props) : props
|
instance.$props = __DEV__ ? immutable(props) : props
|
||||||
instance.$attrs = options
|
instance.$attrs = options
|
||||||
? __DEV__
|
? __DEV__
|
||||||
@ -68,18 +68,18 @@ export function initializeProps(
|
|||||||
const EMPTY_PROPS = [EMPTY_OBJ, EMPTY_OBJ] as [Data, Data]
|
const EMPTY_PROPS = [EMPTY_OBJ, EMPTY_OBJ] as [Data, Data]
|
||||||
|
|
||||||
export function resolveProps(
|
export function resolveProps(
|
||||||
rawData: any,
|
rawProps: any,
|
||||||
_options: ComponentPropsOptions | void
|
_options: ComponentPropsOptions | void
|
||||||
): [Data, Data] {
|
): [Data, Data] {
|
||||||
const hasDeclaredProps = _options != null
|
const hasDeclaredProps = _options != null
|
||||||
const options = normalizePropsOptions(_options) as NormalizedPropsOptions
|
const options = normalizePropsOptions(_options) as NormalizedPropsOptions
|
||||||
if (!rawData && !hasDeclaredProps) {
|
if (!rawProps && !hasDeclaredProps) {
|
||||||
return EMPTY_PROPS
|
return EMPTY_PROPS
|
||||||
}
|
}
|
||||||
const props: any = {}
|
const props: any = {}
|
||||||
let attrs: any = void 0
|
let attrs: any = void 0
|
||||||
if (rawData != null) {
|
if (rawProps != null) {
|
||||||
for (const key in rawData) {
|
for (const key in rawProps) {
|
||||||
// key, ref, slots are reserved
|
// key, ref, slots are reserved
|
||||||
if (key === 'key' || key === 'ref' || key === 'slots') {
|
if (key === 'key' || key === 'ref' || key === 'slots') {
|
||||||
continue
|
continue
|
||||||
@ -87,9 +87,9 @@ export function resolveProps(
|
|||||||
// any non-declared data are put into a separate `attrs` object
|
// any non-declared data are put into a separate `attrs` object
|
||||||
// for spreading
|
// for spreading
|
||||||
if (hasDeclaredProps && !options.hasOwnProperty(key)) {
|
if (hasDeclaredProps && !options.hasOwnProperty(key)) {
|
||||||
;(attrs || (attrs = {}))[key] = rawData[key]
|
;(attrs || (attrs = {}))[key] = rawProps[key]
|
||||||
} else {
|
} else {
|
||||||
props[key] = rawData[key]
|
props[key] = rawProps[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,8 +118,8 @@ export function resolveProps(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// runtime validation
|
// runtime validation
|
||||||
if (__DEV__ && rawData) {
|
if (__DEV__ && rawProps) {
|
||||||
validateProp(key, unwrap(rawData[key]), opt, isAbsent)
|
validateProp(key, unwrap(rawProps[key]), opt, isAbsent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user