mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Add _.isFunction test for NodeList instances.
This commit is contained in:
committed by
John-David Dalton
parent
211a6cc4f1
commit
ffd3e17364
@@ -8187,8 +8187,9 @@
|
|||||||
*/
|
*/
|
||||||
function isFunction(value) {
|
function isFunction(value) {
|
||||||
// The use of `Object#toString` avoids issues with the `typeof` operator
|
// The use of `Object#toString` avoids issues with the `typeof` operator
|
||||||
// in older versions of Chrome and Safari which return 'function' for regexes
|
// in older versions of Chrome and Safari which return 'function' for regexes,
|
||||||
// and Safari 8 which returns 'object' for typed array constructors.
|
// Safari 8 which returns 'object' for typed array constructors, and PhantomJS 1.9
|
||||||
|
// which returns 'function' for `NodeList` instances.
|
||||||
return isObject(value) && objToString.call(value) == funcTag;
|
return isObject(value) && objToString.call(value) == funcTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7338,7 +7338,7 @@
|
|||||||
deepEqual(actual, expected);
|
deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return `false` for non-functions', 11, function() {
|
test('should return `false` for non-functions', 12, function() {
|
||||||
var expected = _.map(falsey, _.constant(false));
|
var expected = _.map(falsey, _.constant(false));
|
||||||
|
|
||||||
var actual = _.map(falsey, function(value, index) {
|
var actual = _.map(falsey, function(value, index) {
|
||||||
@@ -7357,6 +7357,12 @@
|
|||||||
strictEqual(_.isFunction(NaN), false);
|
strictEqual(_.isFunction(NaN), false);
|
||||||
strictEqual(_.isFunction(/x/), false);
|
strictEqual(_.isFunction(/x/), false);
|
||||||
strictEqual(_.isFunction('a'), false);
|
strictEqual(_.isFunction('a'), false);
|
||||||
|
|
||||||
|
if (document) {
|
||||||
|
strictEqual(_.isFunction(document.getElementsByTagName('body')), false);
|
||||||
|
} else {
|
||||||
|
skipTest();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should work with host objects in IE 8 document mode (test in IE 11)', 2, function() {
|
test('should work with host objects in IE 8 document mode (test in IE 11)', 2, function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user