Socket
Socket
Sign inDemoInstall

is-callable

Package Overview
Dependencies
0
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.6 to 1.2.7

13

CHANGELOG.md

@@ -8,2 +8,15 @@ # Changelog

## [v1.2.7](https://github.com/inspect-js/is-callable/compare/v1.2.6...v1.2.7) - 2022-09-23
### Commits
- [Fix] recognize `document.all` in IE 6-10 [`06c1db2`](https://github.com/inspect-js/is-callable/commit/06c1db2b9b2e0f28428e1293eb572f8f93871ec7)
- [Tests] improve logic for FF 20-35 [`0f7d9b9`](https://github.com/inspect-js/is-callable/commit/0f7d9b9c7fe149ca87e71f0a125ade251a6a578c)
- [Fix] handle `document.all` in FF 27 (and +, probably) [`696c661`](https://github.com/inspect-js/is-callable/commit/696c661b8c0810c2d05ab172f1607f4e77ddf81e)
- [Tests] fix proxy tests in FF 42-63 [`985df0d`](https://github.com/inspect-js/is-callable/commit/985df0dd36f8cfe6f1993657b7c0f4cfc19dae30)
- [readme] update tested browsers [`389e919`](https://github.com/inspect-js/is-callable/commit/389e919493b1cb2010126b0411e5291bf76169bd)
- [Fix] detect `document.all` in Opera 12.16 [`b9f1022`](https://github.com/inspect-js/is-callable/commit/b9f1022b3d7e466b7f09080bd64c253caf644325)
- [Fix] HTML elements: properly report as callable in Opera 12.16 [`17391fe`](https://github.com/inspect-js/is-callable/commit/17391fe02b895777c4337be28dca3b364b743b34)
- [Tests] fix inverted logic in FF3 test [`056ebd4`](https://github.com/inspect-js/is-callable/commit/056ebd48790f46ca18ff5b12f51b44c08ccc3595)
## [v1.2.6](https://github.com/inspect-js/is-callable/compare/v1.2.5...v1.2.6) - 2022-09-14

@@ -10,0 +23,0 @@

20

index.js

@@ -49,3 +49,5 @@ 'use strict';

var genClass = '[object GeneratorFunction]';
var ddaClass = '[object HTMLAllCollection]';
var ddaClass = '[object HTMLAllCollection]'; // IE 11
var ddaClass2 = '[object HTML document.all class]';
var ddaClass3 = '[object HTMLCollection]'; // IE 9-10
var hasToStringTag = typeof Symbol === 'function' && !!Symbol.toStringTag; // better: use `has-tostringtag`

@@ -57,3 +59,3 @@

if (typeof document === 'object') {
// Firefox 3 canonicalized DDA to undefined when it's not accessed directly
// Firefox 3 canonicalizes DDA to undefined when it's not accessed directly
var all = document.all;

@@ -67,4 +69,8 @@ if (toStr.call(all) === toStr.call(document.all)) {

var str = toStr.call(value);
// IE 6-8 uses `objectClass`
return (str === ddaClass || str === objectClass) && value('') == null; // eslint-disable-line eqeqeq
return (
str === ddaClass
|| str === ddaClass2
|| str === ddaClass3 // opera 12.16
|| str === objectClass // IE 6-8
) && value('') == null; // eslint-disable-line eqeqeq
} catch (e) { /**/ }

@@ -82,3 +88,2 @@ }

if (typeof value !== 'function' && typeof value !== 'object') { return false; }
if (typeof value === 'function' && !value.prototype) { return true; }
try {

@@ -89,3 +94,3 @@ reflectApply(value, null, badArrayLike);

}
return !isES6ClassFn(value);
return !isES6ClassFn(value) && tryFunctionObject(value);
}

@@ -99,3 +104,4 @@ : function isCallable(value) {

var strClass = toStr.call(value);
return strClass === fnClass || strClass === genClass || tryFunctionObject(value);
if (strClass !== fnClass && strClass !== genClass && !(/^\[object HTML/).test(strClass)) { return false; }
return tryFunctionObject(value);
};
{
"name": "is-callable",
"version": "1.2.6",
"version": "1.2.7",
"author": {

@@ -5,0 +5,0 @@ "name": "Jordan Harband",

@@ -23,5 +23,8 @@ # is-callable <sup>[![Version Badge][2]][1]</sup>

- Firefox: v3, v3.6, v4 - v105 <sub>(every integer version)</sub>
- Note: Firefox v45 - v54 has `class`, but `Function.prototype.toString` hides that progeny and makes them look like functions, so `class` constructors will be reported by this package as callable, when they are not in fact callable.
- Note: v45 - v54 has `class`, but `Function.prototype.toString` hides that progeny and makes them look like functions, so `class` constructors will be reported by this package as callable, when they are not in fact callable.
- Note: in v42 - v63, `Function.prototype.toString` throws on HTML element constructors, or a Proxy to a function
- Note: in v20 - v35, HTML element constructors are not callable, despite having typeof `function`.
- Note: in v19, `document.all` is not callable.
- IE: v6 - v11<sub>(every integer version</sub>
- Opera: v11.1, v11.5, v11.6, 12?, v12.1, v12.12?, v12.14, v12.15, v12.16, v15+ <sub>v15+ matches Chrome</sub>
- Opera: v11.1, v11.5, v11.6, v12.1, v12.14, v12.15, v12.16, v15+ <sub>v15+ matches Chrome</sub>

@@ -28,0 +31,0 @@ ## Example

@@ -51,7 +51,4 @@ 'use strict';

} catch (_) {
// If `Reflect` is supported, then `Function.prototype.toString` isn't used for callability detection.
if (typeof Reflect !== 'object') {
// Older engines throw a `TypeError` when `Function.prototype.toString` is called on a Proxy object.
proxy = null;
}
// Older engines throw a `TypeError` when `Function.prototype.toString` is called on a Proxy object.
proxy = null;
}

@@ -188,3 +185,3 @@ }

test('proxies of functions', { skip: !proxy }, function (t) {
t.ok(isCallable(proxy), 'proxies of functions are callable');
t.equal(isCallable(proxy), true, 'proxies of functions are callable');
t.end();

@@ -207,4 +204,10 @@ });

var all = document.all;
var isFF3 = Object.prototype.toString(all) === Object.prototype.toString.call(document.all);
st.equal(isCallable(document.all), isFF3, 'document.all is ' + (isFF3 ? 'not ' : '') + 'callable');
var isFF3 = !isIE68 && Object.prototype.toString(all) === Object.prototype.toString.call(document.all); // this test is true in IE 6-8 also
var expected = false;
if (!isFF3) {
try {
expected = document.all('') == null; // eslint-disable-line eqeqeq
} catch (e) { /**/ }
}
st.equal(isCallable(document.all), expected, 'document.all is ' + (isFF3 ? 'not ' : '') + 'callable');

@@ -223,4 +226,18 @@ st.end();

st.equal(isCallable(constructor), typeof constructor === 'function', name + ' is ' + (isIE68 ? 'not ' : '') + 'callable');
var callable = isCallable(constructor);
st.equal(typeof callable, 'boolean');
if (callable) {
st.doesNotThrow(
function () { Function.prototype.toString.call(constructor); },
'anything this library claims is callable should be accepted by Function toString'
);
} else {
st['throws'](
function () { Function.prototype.toString.call(constructor); },
TypeError,
'anything this library claims is not callable should not be accepted by Function toString'
);
}
st.end();

@@ -227,0 +244,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc