From d956a0dacb5d8fc20098614e407e1248875f263a Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 13 Jul 2022 09:22:30 +0100 Subject: [PATCH] fix(runtime-core): only set cache for object keys --- packages/runtime-core/src/componentEmits.ts | 8 ++++++-- packages/runtime-core/src/componentOptions.ts | 5 +++-- packages/runtime-core/src/componentProps.ts | 8 ++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/runtime-core/src/componentEmits.ts b/packages/runtime-core/src/componentEmits.ts index 68393c80b35..1e7c812c39e 100644 --- a/packages/runtime-core/src/componentEmits.ts +++ b/packages/runtime-core/src/componentEmits.ts @@ -226,7 +226,9 @@ export function normalizeEmitsOptions( } if (!raw && !hasExtends) { - cache.set(comp, null) + if (comp && typeof comp === 'object') { + cache.set(comp, null) + } return null } @@ -236,7 +238,9 @@ export function normalizeEmitsOptions( extend(normalized, raw) } - cache.set(comp, normalized) + if (comp && typeof comp === 'object') { + cache.set(comp, normalized) + } return normalized } diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index 0d47e18c4af..34940c74820 100644 --- a/packages/runtime-core/src/componentOptions.ts +++ b/packages/runtime-core/src/componentOptions.ts @@ -966,8 +966,9 @@ export function resolveMergedOptions( } mergeOptions(resolved, base, optionMergeStrategies) } - - cache.set(base, resolved) + if (base && typeof base === 'object') { + cache.set(base, resolved) + } return resolved } diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index e046342db35..a27eb50be02 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -494,7 +494,9 @@ export function normalizePropsOptions( } if (!raw && !hasExtends) { - cache.set(comp, EMPTY_ARR as any) + if (comp && typeof comp === 'object') { + cache.set(comp, EMPTY_ARR as any) + } return EMPTY_ARR as any } @@ -534,7 +536,9 @@ export function normalizePropsOptions( } const res: NormalizedPropsOptions = [normalized, needCastKeys] - cache.set(comp, res) + if (comp && typeof comp === 'object') { + cache.set(comp, res) + } return res }