Просмотр исходного кода

fix(runtime-core): only set cache for object keys (#6266)

Daniel Roe 3 лет назад
Родитель
Сommit
c3465c1e88

+ 7 - 2
packages/runtime-core/src/componentEmits.ts

@@ -7,6 +7,7 @@ import {
   hyphenate,
   isArray,
   isFunction,
+  isObject,
   isOn,
   toNumber,
   UnionToIntersection
@@ -226,7 +227,9 @@ export function normalizeEmitsOptions(
   }
 
   if (!raw && !hasExtends) {
-    cache.set(comp, null)
+    if (isObject(comp)) {
+      cache.set(comp, null)
+    }
     return null
   }
 
@@ -236,7 +239,9 @@ export function normalizeEmitsOptions(
     extend(normalized, raw)
   }
 
-  cache.set(comp, normalized)
+  if (isObject(comp)) {
+    cache.set(comp, normalized)
+  }
   return normalized
 }
 

+ 3 - 2
packages/runtime-core/src/componentOptions.ts

@@ -966,8 +966,9 @@ export function resolveMergedOptions(
     }
     mergeOptions(resolved, base, optionMergeStrategies)
   }
-
-  cache.set(base, resolved)
+  if (isObject(base)) {
+    cache.set(base, resolved)
+  }
   return resolved
 }
 

+ 6 - 2
packages/runtime-core/src/componentProps.ts

@@ -494,7 +494,9 @@ export function normalizePropsOptions(
   }
 
   if (!raw && !hasExtends) {
-    cache.set(comp, EMPTY_ARR as any)
+    if (isObject(comp)) {
+      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 (isObject(comp)) {
+    cache.set(comp, res)
+  }
   return res
 }