|
|
@@ -81,6 +81,7 @@ export function initProps(
|
|
|
instance: ComponentInternalInstance,
|
|
|
rawProps: RawProps,
|
|
|
isStateful: boolean,
|
|
|
+ once: boolean,
|
|
|
) {
|
|
|
if (!rawProps) rawProps = []
|
|
|
else if (!isArray(rawProps)) rawProps = [rawProps]
|
|
|
@@ -97,16 +98,16 @@ export function initProps(
|
|
|
for (const key in options) {
|
|
|
const getter = () =>
|
|
|
getDynamicPropValue(rawProps as NormalizedRawProps, key)
|
|
|
- registerProp(instance, props, key, getter, true)
|
|
|
+ registerProp(instance, once, props, key, getter, true)
|
|
|
}
|
|
|
} else {
|
|
|
const staticProps = rawProps[0] as StaticProps
|
|
|
for (const key in options) {
|
|
|
const rawKey = staticProps && getRawKey(staticProps, key)
|
|
|
if (rawKey) {
|
|
|
- registerProp(instance, props, key, staticProps[rawKey])
|
|
|
+ registerProp(instance, once, props, key, staticProps[rawKey])
|
|
|
} else {
|
|
|
- registerProp(instance, props, key, undefined, false, true)
|
|
|
+ registerProp(instance, once, props, key, undefined, false, true)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -133,6 +134,7 @@ export function initProps(
|
|
|
|
|
|
function registerProp(
|
|
|
instance: ComponentInternalInstance,
|
|
|
+ once: boolean,
|
|
|
props: Data,
|
|
|
rawKey: string,
|
|
|
getter?: (() => unknown) | (() => DynamicPropResult),
|
|
|
@@ -158,10 +160,9 @@ function registerProp(
|
|
|
? () => withCast(getter!())
|
|
|
: getter!
|
|
|
|
|
|
- Object.defineProperty(props, key, {
|
|
|
- get,
|
|
|
- enumerable: true,
|
|
|
- })
|
|
|
+ const descriptor: PropertyDescriptor = once ? { value: get() } : { get }
|
|
|
+ descriptor.enumerable = true
|
|
|
+ Object.defineProperty(props, key, descriptor)
|
|
|
}
|
|
|
}
|
|
|
|