mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Fix IE 9 test fails.
This commit is contained in:
10
lodash.js
10
lodash.js
@@ -3231,7 +3231,7 @@
|
|||||||
return nativeKeys(object);
|
return nativeKeys(object);
|
||||||
}
|
}
|
||||||
var result = [];
|
var result = [];
|
||||||
for (var key in object) {
|
for (var key in Object(object)) {
|
||||||
if (hasOwnProperty.call(object, key) && key != 'constructor') {
|
if (hasOwnProperty.call(object, key) && key != 'constructor') {
|
||||||
result.push(key);
|
result.push(key);
|
||||||
}
|
}
|
||||||
@@ -3247,7 +3247,7 @@
|
|||||||
* @returns {Array} Returns the array of property names.
|
* @returns {Array} Returns the array of property names.
|
||||||
*/
|
*/
|
||||||
function baseKeysIn(object) {
|
function baseKeysIn(object) {
|
||||||
if (object == null || !('constructor' in Object(object))) {
|
if (!isObject(object)) {
|
||||||
return nativeKeysIn(object);
|
return nativeKeysIn(object);
|
||||||
}
|
}
|
||||||
var isProto = isPrototype(object),
|
var isProto = isPrototype(object),
|
||||||
@@ -6127,8 +6127,10 @@
|
|||||||
*/
|
*/
|
||||||
function nativeKeysIn(object) {
|
function nativeKeysIn(object) {
|
||||||
var result = [];
|
var result = [];
|
||||||
for (var key in object) {
|
if (object != null) {
|
||||||
result.push(key);
|
for (var key in Object(object)) {
|
||||||
|
result.push(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
83
test/test.js
83
test/test.js
@@ -12929,16 +12929,6 @@
|
|||||||
delete numberProto.a;
|
delete numberProto.a;
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('`_.' + methodName + '` should not coerce nullish values to objects', function(assert) {
|
|
||||||
assert.expect(2);
|
|
||||||
|
|
||||||
objectProto.a = 1;
|
|
||||||
lodashStable.each([null, undefined], function(value) {
|
|
||||||
assert.deepEqual(func(value), []);
|
|
||||||
});
|
|
||||||
delete objectProto.a;
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test('`_.' + methodName + '` skips the `constructor` property on prototype objects', function(assert) {
|
QUnit.test('`_.' + methodName + '` skips the `constructor` property on prototype objects', function(assert) {
|
||||||
assert.expect(3);
|
assert.expect(3);
|
||||||
|
|
||||||
@@ -12955,6 +12945,20 @@
|
|||||||
Fake.prototype.constructor = Fake;
|
Fake.prototype.constructor = Fake;
|
||||||
assert.deepEqual(func(Fake.prototype), ['constructor']);
|
assert.deepEqual(func(Fake.prototype), ['constructor']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('`_.' + methodName + '` should return an empty array when `object` is nullish', function(assert) {
|
||||||
|
var values = [, null, undefined],
|
||||||
|
expected = lodashStable.map(values, stubArray);
|
||||||
|
|
||||||
|
var actual = lodashStable.map(values, function(value, index) {
|
||||||
|
objectProto.a = 1;
|
||||||
|
var result = index ? func(value) : func();
|
||||||
|
delete objectProto.a;
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(actual, expected);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
@@ -14032,14 +14036,22 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should return `false` if parts of `path` are missing', function(assert) {
|
QUnit.test('should return `false` when `object` is nullish', function(assert) {
|
||||||
assert.expect(4);
|
assert.expect(2);
|
||||||
|
|
||||||
var object = {};
|
var values = [, null, undefined],
|
||||||
|
expected = lodashStable.map(values, stubFalse);
|
||||||
|
|
||||||
lodashStable.each(['a', 'a[1].b.c', ['a'], ['a', '1', 'b', 'c']], function(path) {
|
lodashStable.each(['constructor', ['constructor']], function(path) {
|
||||||
var matches = _.matchesProperty(path, 1);
|
var matches = _.matchesProperty(path, 1);
|
||||||
assert.strictEqual(matches(object), false);
|
|
||||||
|
var actual = lodashStable.map(values, function(value, index) {
|
||||||
|
try {
|
||||||
|
return index ? matches(value) : matches();
|
||||||
|
} catch (e) {}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -14062,6 +14074,17 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should return `false` if parts of `path` are missing', function(assert) {
|
||||||
|
assert.expect(4);
|
||||||
|
|
||||||
|
var object = {};
|
||||||
|
|
||||||
|
lodashStable.each(['a', 'a[1].b.c', ['a'], ['a', '1', 'b', 'c']], function(path) {
|
||||||
|
var matches = _.matchesProperty(path, 1);
|
||||||
|
assert.strictEqual(matches(object), false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('should match inherited string keyed `srcValue` properties', function(assert) {
|
QUnit.test('should match inherited string keyed `srcValue` properties', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
@@ -14300,25 +14323,6 @@
|
|||||||
delete numberProto.b;
|
delete numberProto.b;
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should return `false` when `object` is nullish', function(assert) {
|
|
||||||
assert.expect(2);
|
|
||||||
|
|
||||||
var values = [, null, undefined],
|
|
||||||
expected = lodashStable.map(values, stubFalse);
|
|
||||||
|
|
||||||
lodashStable.each(['constructor', ['constructor']], function(path) {
|
|
||||||
var matches = _.matchesProperty(path, 1);
|
|
||||||
|
|
||||||
var actual = lodashStable.map(values, function(value, index) {
|
|
||||||
try {
|
|
||||||
return index ? matches(value) : matches();
|
|
||||||
} catch (e) {}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.deepEqual(actual, expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
QUnit.test('should return `true` when comparing a `srcValue` of empty arrays and objects', function(assert) {
|
QUnit.test('should return `true` when comparing a `srcValue` of empty arrays and objects', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
@@ -16212,11 +16216,12 @@
|
|||||||
QUnit.test('should return an empty object when `object` is nullish', function(assert) {
|
QUnit.test('should return an empty object when `object` is nullish', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
objectProto.a = 1;
|
|
||||||
lodashStable.each([null, undefined], function(value) {
|
lodashStable.each([null, undefined], function(value) {
|
||||||
assert.deepEqual(_.omit(value, 'valueOf'), {});
|
objectProto.a = 1;
|
||||||
|
var actual = _.omit(value, 'valueOf');
|
||||||
|
delete objectProto.a;
|
||||||
|
assert.deepEqual(actual, {});
|
||||||
});
|
});
|
||||||
delete objectProto.a;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should work with `arguments` objects as secondary arguments', function(assert) {
|
QUnit.test('should work with `arguments` objects as secondary arguments', function(assert) {
|
||||||
@@ -19818,10 +19823,10 @@
|
|||||||
|
|
||||||
QUnit.test('`_.' + methodName + '` should overwrite primitives in the path', function(assert) {
|
QUnit.test('`_.' + methodName + '` should overwrite primitives in the path', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
lodashStable.each(['a.b', ['a', 'b']], function(path) {
|
lodashStable.each(['a.b', ['a', 'b']], function(path) {
|
||||||
var object = { 'a': '' };
|
var object = { 'a': '' };
|
||||||
|
|
||||||
func(object, path, updater);
|
func(object, path, updater);
|
||||||
assert.deepEqual(object, { 'a': { 'b': 2 } });
|
assert.deepEqual(object, { 'a': { 'b': 2 } });
|
||||||
});;
|
});;
|
||||||
|
|||||||
Reference in New Issue
Block a user