Skip to content

Commit d84ee39

Browse files
cs1707abigail-0111
authored andcommitted
fix: update isFunction (ElemeFE#20912)
1 parent 6e78a17 commit d84ee39

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/utils/types.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import Vue from 'vue';
2+
13
export function isString(obj) {
24
return Object.prototype.toString.call(obj) === '[object String]';
35
}
@@ -10,11 +12,25 @@ export function isHtmlElement(node) {
1012
return node && node.nodeType === Node.ELEMENT_NODE;
1113
}
1214

13-
export const isFunction = (functionToCheck) => {
15+
/**
16+
* - Inspired:
17+
* https://github.com/jashkenas/underscore/blob/master/modules/isFunction.js
18+
*/
19+
let isFunction = (functionToCheck) => {
1420
var getType = {};
1521
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
1622
};
1723

24+
if (typeof /./ !== 'function' && typeof Int8Array !== 'object' && (Vue.prototype.$isServer || typeof document.childNodes !== 'function')) {
25+
isFunction = function(obj) {
26+
return typeof obj === 'function' || false;
27+
};
28+
}
29+
30+
export {
31+
isFunction
32+
};
33+
1834
export const isUndefined = (val)=> {
1935
return val === void 0;
2036
};

0 commit comments

Comments
 (0)