Skip to content

Commit e1b9757

Browse files
HcySunYangliximomo
authored andcommitted
fix: correct the symbol check (#218)
close #116
1 parent 3b7eadf commit e1b9757

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import Vue from 'vue';
22

33
const toString = (x: any) => Object.prototype.toString.call(x);
44

5-
export const hasSymbol = typeof Symbol === 'function' && Symbol.for;
5+
export function isNative (Ctor: any): boolean {
6+
return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
7+
}
8+
9+
export const hasSymbol =
10+
typeof Symbol !== 'undefined' && isNative(Symbol) &&
11+
typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys)
612

713
export const noopFn: any = (_: any) => _;
814

0 commit comments

Comments
 (0)