Skip to content

Commit

Permalink
fix: correct the symbol check (vuejs#218)
Browse files Browse the repository at this point in the history
close vuejs#116
  • Loading branch information
HcySunYang authored and pikax committed Apr 19, 2020
1 parent 71896f5 commit af1dd40
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import Vue from 'vue';

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

export const hasSymbol = typeof Symbol === 'function' && Symbol.for;
export function isNative (Ctor: any): boolean {
return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
}

export const hasSymbol =
typeof Symbol !== 'undefined' && isNative(Symbol) &&
typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys)

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

Expand Down

0 comments on commit af1dd40

Please sign in to comment.