From 0418a47148f4f2562099cc6eb55ca7040ecaad27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=BD=E5=A4=9A=E5=A4=A7=E7=B1=B3?= Date: Thu, 8 Apr 2021 17:13:39 +0800 Subject: [PATCH] fix: update isFunction (#20912) --- src/utils/types.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/utils/types.js b/src/utils/types.js index bfcceed5f..7f6bdeb56 100644 --- a/src/utils/types.js +++ b/src/utils/types.js @@ -1,3 +1,5 @@ +import Vue from 'vue'; + export function isString(obj) { return Object.prototype.toString.call(obj) === '[object String]'; } @@ -10,11 +12,25 @@ export function isHtmlElement(node) { return node && node.nodeType === Node.ELEMENT_NODE; } -export const isFunction = (functionToCheck) => { +/** + * - Inspired: + * https://github.com/jashkenas/underscore/blob/master/modules/isFunction.js + */ +let isFunction = (functionToCheck) => { var getType = {}; return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; }; +if (typeof /./ !== 'function' && typeof Int8Array !== 'object' && (Vue.prototype.$isServer || typeof document.childNodes !== 'function')) { + isFunction = function(obj) { + return typeof obj === 'function' || false; + }; +} + +export { + isFunction +}; + export const isUndefined = (val)=> { return val === void 0; };