refactor: remove useless argument
This commit is contained in:
parent
c4481a49e8
commit
f3d7c9e152
@ -1,9 +1,5 @@
|
|||||||
import { immutable, unwrap, lock, unlock } from '@vue/observer'
|
import { immutable, unwrap, lock, unlock } from '@vue/observer'
|
||||||
import {
|
import { MountedComponent } from './component'
|
||||||
ComponentClass,
|
|
||||||
MountedComponent,
|
|
||||||
FunctionalComponent
|
|
||||||
} from './component'
|
|
||||||
import {
|
import {
|
||||||
Data,
|
Data,
|
||||||
ComponentPropsOptions,
|
ComponentPropsOptions,
|
||||||
@ -21,11 +17,7 @@ import {
|
|||||||
} from './utils'
|
} from './utils'
|
||||||
|
|
||||||
export function initializeProps(instance: MountedComponent, data: Data | null) {
|
export function initializeProps(instance: MountedComponent, data: Data | null) {
|
||||||
const { props, attrs } = resolveProps(
|
const { props, attrs } = resolveProps(data, instance.$options.props)
|
||||||
data,
|
|
||||||
instance.$options.props,
|
|
||||||
instance.constructor as ComponentClass
|
|
||||||
)
|
|
||||||
instance.$props = immutable(props || {})
|
instance.$props = immutable(props || {})
|
||||||
instance.$attrs = immutable(attrs || {})
|
instance.$attrs = immutable(attrs || {})
|
||||||
}
|
}
|
||||||
@ -37,8 +29,7 @@ export function updateProps(instance: MountedComponent, nextData: Data) {
|
|||||||
if (nextData != null) {
|
if (nextData != null) {
|
||||||
const { props: nextProps, attrs: nextAttrs } = resolveProps(
|
const { props: nextProps, attrs: nextAttrs } = resolveProps(
|
||||||
nextData,
|
nextData,
|
||||||
instance.$options.props,
|
instance.$options.props
|
||||||
instance.constructor as ComponentClass
|
|
||||||
)
|
)
|
||||||
// unlock to temporarily allow mutatiing props
|
// unlock to temporarily allow mutatiing props
|
||||||
unlock()
|
unlock()
|
||||||
@ -79,8 +70,7 @@ const EMPTY_PROPS = { props: EMPTY_OBJ }
|
|||||||
// - else: everything goes in `props`.
|
// - else: everything goes in `props`.
|
||||||
export function resolveProps(
|
export function resolveProps(
|
||||||
rawData: any,
|
rawData: any,
|
||||||
rawOptions: ComponentPropsOptions | void,
|
rawOptions: ComponentPropsOptions | void
|
||||||
Component: ComponentClass | FunctionalComponent
|
|
||||||
): { props: Data; attrs?: Data } {
|
): { props: Data; attrs?: Data } {
|
||||||
const hasDeclaredProps = rawOptions !== void 0
|
const hasDeclaredProps = rawOptions !== void 0
|
||||||
if (!rawData && !hasDeclaredProps) {
|
if (!rawData && !hasDeclaredProps) {
|
||||||
@ -141,7 +131,7 @@ export function resolveProps(
|
|||||||
}
|
}
|
||||||
// runtime validation
|
// runtime validation
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
validateProp(key, unwrap(rawData[key]), opt, Component, isAbsent)
|
validateProp(key, unwrap(rawData[key]), opt, isAbsent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,7 +229,6 @@ function validateProp(
|
|||||||
name: string,
|
name: string,
|
||||||
value: any,
|
value: any,
|
||||||
prop: PropOptions<any>,
|
prop: PropOptions<any>,
|
||||||
Component: ComponentClass | FunctionalComponent,
|
|
||||||
isAbsent: boolean
|
isAbsent: boolean
|
||||||
) {
|
) {
|
||||||
const { type, required, validator } = prop
|
const { type, required, validator } = prop
|
||||||
|
Loading…
Reference in New Issue
Block a user