]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(reactivity): use function isSymbol instead of typeof (#155)
authorCr <631807682@qq.com>
Wed, 9 Oct 2019 15:49:23 +0000 (23:49 +0800)
committerEvan You <yyx990803@gmail.com>
Wed, 9 Oct 2019 15:49:23 +0000 (11:49 -0400)
packages/reactivity/src/baseHandlers.ts

index ff163179f8bbcc48561db93d04716b65a219a732..fe07600d9f3a4a2fbb1128206953b0347c2a5da2 100644 (file)
@@ -2,19 +2,19 @@ import { reactive, readonly, toRaw } from './reactive'
 import { OperationTypes } from './operations'
 import { track, trigger } from './effect'
 import { LOCKED } from './lock'
-import { isObject, hasOwn } from '@vue/shared'
+import { isObject, hasOwn, isSymbol } from '@vue/shared'
 import { isRef } from './ref'
 
 const builtInSymbols = new Set(
   Object.getOwnPropertyNames(Symbol)
     .map(key => (Symbol as any)[key])
-    .filter(value => typeof value === 'symbol')
+    .filter(isSymbol)
 )
 
 function createGetter(isReadonly: boolean) {
   return function get(target: any, key: string | symbol, receiver: any) {
     const res = Reflect.get(target, key, receiver)
-    if (typeof key === 'symbol' && builtInSymbols.has(key)) {
+    if (isSymbol(key) && builtInSymbols.has(key)) {
       return res
     }
     if (isRef(res)) {