From ffd3e173644a0e32a01787e49ccb8d229c6fdb17 Mon Sep 17 00:00:00 2001 From: Graeme Yeates Date: Sun, 12 Jul 2015 19:12:13 -0400 Subject: [PATCH] Add `_.isFunction` test for `NodeList` instances. --- lodash.src.js | 5 +++-- test/test.js | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index b16d4ddb8..4f5c101e6 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -8187,8 +8187,9 @@ */ function isFunction(value) { // The use of `Object#toString` avoids issues with the `typeof` operator - // in older versions of Chrome and Safari which return 'function' for regexes - // and Safari 8 which returns 'object' for typed array constructors. + // in older versions of Chrome and Safari which return 'function' for regexes, + // 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; } diff --git a/test/test.js b/test/test.js index 4dded1f69..0a9da57fa 100644 --- a/test/test.js +++ b/test/test.js @@ -7338,7 +7338,7 @@ 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 actual = _.map(falsey, function(value, index) { @@ -7357,6 +7357,12 @@ strictEqual(_.isFunction(NaN), false); strictEqual(_.isFunction(/x/), 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() {