components: Record<string, Component>
directives: Record<string, Directive>
provides: Record<string | symbol, any>
- reload?: () => void // HMR only
+ /**
+ * Flag for de-optimizing props normalization
+ * @internal
+ */
+ deopt?: boolean
+ /**
+ * HMR only
+ * @internal
+ */
+ reload?: () => void
}
type PluginInstallFunction = (app: App, ...options: any[]) => any
if (__FEATURE_OPTIONS_API__) {
if (!context.mixins.includes(mixin)) {
context.mixins.push(mixin)
+ // global mixin with props/emits de-optimizes props/emits
+ // normalization caching.
+ if (mixin.props || mixin.emits) {
+ context.deopt = true
+ }
} else if (__DEV__) {
warn(
'Mixin has already been applied to target app' +
/**
* @internal
*/
- __props?: Record<number, NormalizedPropsOptions>
+ __props?: NormalizedPropsOptions
/**
* @internal
*/
- __emits?: Record<number, ObjectEmitsOptions | null>
+ __emits?: ObjectEmitsOptions | null
/**
* @internal
*/
appContext: AppContext,
asMixin = false
): ObjectEmitsOptions | null {
- const appId = appContext.app ? appContext.app._uid : -1
- const cache = comp.__emits || (comp.__emits = {})
- const cached = cache[appId]
- if (cached !== undefined) {
- return cached
+ if (!appContext.deopt && comp.__emits !== undefined) {
+ return comp.__emits
}
const raw = comp.emits
}
if (!raw && !hasExtends) {
- return (cache[appId] = null)
+ return (comp.__emits = null)
}
if (isArray(raw)) {
} else {
extend(normalized, raw)
}
- return (cache[appId] = normalized)
+ return (comp.__emits = normalized)
}
// Check if an incoming prop key is a declared emit event listener.
appContext: AppContext,
asMixin = false
): NormalizedPropsOptions {
- const appId = appContext.app ? appContext.app._uid : -1
- const cache = comp.__props || (comp.__props = {})
- const cached = cache[appId]
- if (cached) {
- return cached
+ if (!appContext.deopt && comp.__props) {
+ return comp.__props
}
const raw = comp.props
}
if (!raw && !hasExtends) {
- return (cache[appId] = EMPTY_ARR)
+ return (comp.__props = EMPTY_ARR)
}
if (isArray(raw)) {
}
}
- return (cache[appId] = [normalized, needCastKeys])
+ return (comp.__props = [normalized, needCastKeys])
+}
+
+function validatePropName(key: string) {
+ if (key[0] !== '$') {
+ return true
+ } else if (__DEV__) {
+ warn(`Invalid prop name: "${key}" is a reserved property.`)
+ }
+ return false
}
// use function string name to check type constructors
}
}
-/**
- * dev only
- */
-function validatePropName(key: string) {
- if (key[0] !== '$') {
- return true
- } else if (__DEV__) {
- warn(`Invalid prop name: "${key}" is a reserved property.`)
- }
- return false
-}
-
/**
* dev only
*/