Explorar el Código

fix(runtime-core): handle validate prop check edge case

daiwei hace 1 año
padre
commit
4ff11301ed

+ 4 - 0
packages/runtime-core/src/componentProps.ts

@@ -21,7 +21,9 @@ import {
   isOn,
   isOn,
   isReservedProp,
   isReservedProp,
   isString,
   isString,
+  isSymbol,
   makeMap,
   makeMap,
+  stringifySymbol,
   toRawType,
   toRawType,
 } from '@vue/shared'
 } from '@vue/shared'
 import { warn } from './warning'
 import { warn } from './warning'
@@ -795,6 +797,8 @@ function styleValue(value: unknown, type: string): string {
     return `"${value}"`
     return `"${value}"`
   } else if (type === 'Number') {
   } else if (type === 'Number') {
     return `${Number(value)}`
     return `${Number(value)}`
+  } else if (isSymbol(value)) {
+    return stringifySymbol(value)
   } else {
   } else {
     return `${value}`
     return `${value}`
   }
   }

+ 1 - 1
packages/shared/src/toDisplayString.ts

@@ -61,7 +61,7 @@ const replacer = (_key: string, val: unknown): any => {
   return val
   return val
 }
 }
 
 
-const stringifySymbol = (v: unknown, i: number | string = ''): any =>
+export const stringifySymbol = (v: unknown, i: number | string = ''): any =>
   // Symbol.description in es2019+ so we need to cast here to pass
   // Symbol.description in es2019+ so we need to cast here to pass
   // the lib: es2016 check
   // the lib: es2016 check
   isSymbol(v) ? `Symbol(${(v as any).description ?? i})` : v
   isSymbol(v) ? `Symbol(${(v as any).description ?? i})` : v