mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Remove nativeAssign and getOwnPropertySymbols use.
This commit is contained in:
@@ -90,15 +90,6 @@
|
||||
setProperty(Date, '_now', Date.now);
|
||||
setProperty(Date, 'now', noop);
|
||||
|
||||
setProperty(Object, '_getOwnPropertySymbols', Object.getOwnPropertySymbols);
|
||||
setProperty(Object, 'getOwnPropertySymbols', (function() {
|
||||
function getOwnPropertySymbols() {
|
||||
return [];
|
||||
}
|
||||
setProperty(getOwnPropertySymbols, 'toString', createToString('getOwnPropertySymbols'));
|
||||
return getOwnPropertySymbols;
|
||||
}()));
|
||||
|
||||
setProperty(Object, '_getPrototypeOf', Object.getPrototypeOf);
|
||||
setProperty(Object, 'getPrototypeOf', noop);
|
||||
|
||||
@@ -204,11 +195,6 @@
|
||||
} else {
|
||||
delete Date.now;
|
||||
}
|
||||
if (Object._getOwnPropertySymbols) {
|
||||
setProperty(Object, 'getOwnPropertySymbols', Object._getOwnPropertySymbols);
|
||||
} else {
|
||||
delete Object.getOwnPropertySymbols;
|
||||
}
|
||||
if (Object._getPrototypeOf) {
|
||||
setProperty(Object, 'getPrototypeOf', Object._getPrototypeOf);
|
||||
} else {
|
||||
@@ -255,7 +241,6 @@
|
||||
|
||||
delete Array._isArray;
|
||||
delete Date._now;
|
||||
delete Object._getOwnPropertySymbols;
|
||||
delete Object._getPrototypeOf;
|
||||
delete Object._keys;
|
||||
delete funcProto._method;
|
||||
|
||||
42
test/test.js
42
test/test.js
@@ -460,15 +460,6 @@
|
||||
var _now = Date.now;
|
||||
setProperty(Date, 'now', _.noop);
|
||||
|
||||
var _getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||||
setProperty(Object, 'getOwnPropertySymbols', (function() {
|
||||
function getOwnPropertySymbols() {
|
||||
return [];
|
||||
}
|
||||
setProperty(getOwnPropertySymbols, 'toString', createToString('getOwnPropertySymbols'));
|
||||
return getOwnPropertySymbols;
|
||||
}()));
|
||||
|
||||
var _getPrototypeOf = Object.getPrototypeOf;
|
||||
setProperty(Object, 'getPrototypeOf', _.noop);
|
||||
|
||||
@@ -561,7 +552,6 @@
|
||||
// Restore built-in methods.
|
||||
setProperty(Array, 'isArray', _isArray);
|
||||
setProperty(Date, 'now', _now);
|
||||
setProperty(Object, 'getOwnPropertySymbols', _getOwnPropertySymbols);
|
||||
setProperty(Object, 'getPrototypeOf', _getPrototypeOf);
|
||||
setProperty(Object, 'keys', _keys);
|
||||
|
||||
@@ -708,7 +698,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
test('should avoid overwritten native methods', 13, function() {
|
||||
test('should avoid overwritten native methods', 12, function() {
|
||||
function Foo() {}
|
||||
|
||||
function message(lodashMethod, nativeMethod) {
|
||||
@@ -734,13 +724,6 @@
|
||||
}
|
||||
ok(typeof actual == 'number', message('_.now', 'Date.now'));
|
||||
|
||||
try {
|
||||
actual = lodashBizarro.merge({}, object);
|
||||
} catch(e) {
|
||||
actual = null;
|
||||
}
|
||||
deepEqual(actual, object, message('_.merge', 'Object.getOwnPropertySymbols'));
|
||||
|
||||
try {
|
||||
actual = [lodashBizarro.isPlainObject({}), lodashBizarro.isPlainObject([])];
|
||||
} catch(e) {
|
||||
@@ -809,7 +792,7 @@
|
||||
}
|
||||
}
|
||||
else {
|
||||
skipTest(13);
|
||||
skipTest(12);
|
||||
}
|
||||
});
|
||||
}());
|
||||
@@ -5862,25 +5845,6 @@
|
||||
deepEqual(func({}, new Foo), { 'a': 1 });
|
||||
});
|
||||
|
||||
test('`_.' + methodName + '` should assign own symbols', 2, function() {
|
||||
if (Symbol) {
|
||||
var symbol1 = Symbol('a'),
|
||||
symbol2 = Symbol('b');
|
||||
|
||||
var Foo = function() {
|
||||
this[symbol1] = 1;
|
||||
};
|
||||
Foo.prototype[symbol2] = 2;
|
||||
|
||||
var actual = func({}, new Foo);
|
||||
strictEqual(actual[symbol1], 1);
|
||||
strictEqual(actual[symbol2], undefined);
|
||||
}
|
||||
else {
|
||||
skipTest(2);
|
||||
}
|
||||
});
|
||||
|
||||
test('`_.' + methodName + '` should assign problem JScript properties (test in IE < 9)', 1, function() {
|
||||
var object = {
|
||||
'constructor': '0',
|
||||
@@ -16486,8 +16450,8 @@
|
||||
});
|
||||
|
||||
test('should work with large arrays of well-known symbols', 1, function() {
|
||||
// See https://people.mozilla.org/~jorendorff/es6-draft.html#sec-well-known-symbols.
|
||||
if (Symbol) {
|
||||
// See https://people.mozilla.org/~jorendorff/es6-draft.html#sec-well-known-symbols.
|
||||
var expected = [
|
||||
Symbol.hasInstance, Symbol.isConcatSpreadable, Symbol.iterator,
|
||||
Symbol.match, Symbol.replace, Symbol.search, Symbol.species,
|
||||
|
||||
Reference in New Issue
Block a user