Skip to content

Commit

Permalink
[Fix] Safari 4: regexes should not be considered callable
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Sep 13, 2022
1 parent 3193735 commit 4b732ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion index.js
Expand Up @@ -74,7 +74,6 @@ module.exports = reflectApply
if (isDDA(value)) { return true; }
if (!value) { return false; }
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
if (typeof value === 'function' && !value.prototype) { return true; }
if (hasToStringTag) { return tryFunctionObject(value); }
if (isES6ClassFn(value)) { return false; }
var strClass = toStr.call(value);
Expand Down
5 changes: 5 additions & 0 deletions test/index.js
Expand Up @@ -78,6 +78,11 @@ test('not callables', function (t) {
new RegExp('a', 'g'),
new Date()
]), function (nonFunction) {
t['throws'](
function () { Function.prototype.toString.call(nonFunction); },
TypeError,
inspect(nonFunction) + ' can not be used with Function toString'
);
t.equal(isCallable(nonFunction), false, inspect(nonFunction) + ' is not callable');
});

Expand Down

0 comments on commit 4b732ff

Please sign in to comment.