mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
This commit is contained in:
10
lodash.js
10
lodash.js
@@ -6595,7 +6595,9 @@
|
|||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function isFunction(value) {
|
function isFunction(value) {
|
||||||
return typeof value == 'function';
|
// avoid a Chakra bug in IE 11
|
||||||
|
// https://github.com/jashkenas/underscore/issues/1621
|
||||||
|
return typeof value == 'function' || false;
|
||||||
}
|
}
|
||||||
// fallback for older versions of Chrome and Safari
|
// fallback for older versions of Chrome and Safari
|
||||||
if (isFunction(/x/)) {
|
if (isFunction(/x/)) {
|
||||||
@@ -6608,6 +6610,8 @@
|
|||||||
* Checks if `value` is the language type of `Object`.
|
* Checks if `value` is the language type of `Object`.
|
||||||
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
||||||
*
|
*
|
||||||
|
* Note: See the [ES5 spec](http://es5.github.io/#x8) for more details.
|
||||||
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Objects
|
* @category Objects
|
||||||
@@ -6625,9 +6629,7 @@
|
|||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function isObject(value) {
|
function isObject(value) {
|
||||||
// check if the value is the ECMAScript language type of `Object`
|
// avoid a V8 bug in Chrome 19-20
|
||||||
// http://es5.github.io/#x8
|
|
||||||
// and avoid a V8 bug
|
|
||||||
// https://code.google.com/p/v8/issues/detail?id=2291
|
// https://code.google.com/p/v8/issues/detail?id=2291
|
||||||
var type = typeof value;
|
var type = typeof value;
|
||||||
return type == 'function' || (value && type == 'object') || false;
|
return type == 'function' || (value && type == 'object') || false;
|
||||||
|
|||||||
40
test/test.js
40
test/test.js
@@ -88,9 +88,14 @@
|
|||||||
/** Detect if running in Rhino */
|
/** Detect if running in Rhino */
|
||||||
var isRhino = isJava && typeof global == 'function' && global().Array === root.Array;
|
var isRhino = isJava && typeof global == 'function' && global().Array === root.Array;
|
||||||
|
|
||||||
/** Detect support for testing Web Workers */
|
/** Used to test Web Workers */
|
||||||
var Worker = !(ui.isForeign || isModularize) && document && root.Worker;
|
var Worker = !(ui.isForeign || isModularize) && document && root.Worker;
|
||||||
|
|
||||||
|
/** Used to test host objects in IE */
|
||||||
|
try {
|
||||||
|
var xml = new ActiveXObject('Microsoft.XMLDOM');
|
||||||
|
} catch(e) { }
|
||||||
|
|
||||||
/** Use a single "load" function */
|
/** Use a single "load" function */
|
||||||
var load = (typeof require == 'function' && !amd)
|
var load = (typeof require == 'function' && !amd)
|
||||||
? require
|
? require
|
||||||
@@ -4987,6 +4992,19 @@
|
|||||||
deepEqual(actual, expected);
|
deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should work with host objects in non-edge document modes (test in IE 11)', 1, function() {
|
||||||
|
if (xml) {
|
||||||
|
// trigger Chakra bug
|
||||||
|
// https://github.com/jashkenas/underscore/issues/1621
|
||||||
|
_.times(100, _.isFunction);
|
||||||
|
|
||||||
|
strictEqual(_.isFunction(xml), false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('should work with functions from another realm', 1, function() {
|
test('should work with functions from another realm', 1, function() {
|
||||||
if (_._object) {
|
if (_._object) {
|
||||||
strictEqual(_.isFunction(_._function), true);
|
strictEqual(_.isFunction(_._function), true);
|
||||||
@@ -5186,18 +5204,18 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should avoid V8 bug #2291', 1, function() {
|
test('should avoid V8 bug #2291 (test in Chrome 19-20)', 1, function() {
|
||||||
// trigger V8 bug
|
// trigger V8 bug
|
||||||
// http://code.google.com/p/v8/issues/detail?id=2291
|
// http://code.google.com/p/v8/issues/detail?id=2291
|
||||||
var obj = {},
|
var object = {};
|
||||||
str = 'foo';
|
|
||||||
|
|
||||||
// 1: Useless comparison statement, this is half the trigger
|
// 1: Useless comparison statement, this is half the trigger
|
||||||
obj == obj;
|
object == object;
|
||||||
// 2: Initial check with object, this is the other half of the trigger
|
|
||||||
_.isObject(obj);
|
|
||||||
|
|
||||||
strictEqual(_.isObject(str), false);
|
// 2: Initial check with object, this is the other half of the trigger
|
||||||
|
_.isObject(object);
|
||||||
|
|
||||||
|
strictEqual(_.isObject('x'), false);
|
||||||
});
|
});
|
||||||
}(1, 2, 3));
|
}(1, 2, 3));
|
||||||
|
|
||||||
@@ -5430,10 +5448,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should not error on host objects (test in IE)', 12, function() {
|
test('should not error on host objects (test in IE)', 12, function() {
|
||||||
try {
|
|
||||||
var xml = new ActiveXObject('Microsoft.XMLDOM');
|
|
||||||
} catch(e) { }
|
|
||||||
|
|
||||||
if (xml) {
|
if (xml) {
|
||||||
var funcs = [
|
var funcs = [
|
||||||
'isArray', 'isArguments', 'isBoolean', 'isDate', 'isElement', 'isFunction',
|
'isArray', 'isArguments', 'isBoolean', 'isDate', 'isElement', 'isFunction',
|
||||||
@@ -10219,7 +10233,7 @@
|
|||||||
QUnit.module('lodash(...).splice');
|
QUnit.module('lodash(...).splice');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
test('should remove the value at index `0` when length is `0` (test in IE < 9, and in compatibility mode for IE9)', 2, function() {
|
test('should remove the value at index `0` when length is `0` (test in IE < 9, and in compatibility mode for IE 9)', 2, function() {
|
||||||
if (!isNpm) {
|
if (!isNpm) {
|
||||||
var wrapped = _({ '0': 1, 'length': 1 });
|
var wrapped = _({ '0': 1, 'length': 1 });
|
||||||
wrapped.splice(0, 1);
|
wrapped.splice(0, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user