mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Restore bizarro tests for Object.create.
This commit is contained in:
@@ -1315,7 +1315,6 @@
|
|||||||
|
|
||||||
/** Built-in value references. */
|
/** Built-in value references. */
|
||||||
var Buffer = moduleExports ? context.Buffer : undefined,
|
var Buffer = moduleExports ? context.Buffer : undefined,
|
||||||
objectCreate = Object.create,
|
|
||||||
Reflect = context.Reflect,
|
Reflect = context.Reflect,
|
||||||
Symbol = context.Symbol,
|
Symbol = context.Symbol,
|
||||||
Uint8Array = context.Uint8Array,
|
Uint8Array = context.Uint8Array,
|
||||||
@@ -1324,6 +1323,7 @@
|
|||||||
getPrototypeOf = Object.getPrototypeOf,
|
getPrototypeOf = Object.getPrototypeOf,
|
||||||
getOwnPropertySymbols = Object.getOwnPropertySymbols,
|
getOwnPropertySymbols = Object.getOwnPropertySymbols,
|
||||||
iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined,
|
iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined,
|
||||||
|
objectCreate = Object.create,
|
||||||
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
||||||
setTimeout = context.setTimeout,
|
setTimeout = context.setTimeout,
|
||||||
splice = arrayProto.splice;
|
splice = arrayProto.splice;
|
||||||
|
|||||||
@@ -82,6 +82,19 @@
|
|||||||
funcProto._method = noop;
|
funcProto._method = noop;
|
||||||
|
|
||||||
// Set bad shims.
|
// Set bad shims.
|
||||||
|
setProperty(Object, '_create', Object.create);
|
||||||
|
setProperty(Object, 'create', (function() {
|
||||||
|
function object() {}
|
||||||
|
return function(prototype) {
|
||||||
|
if (prototype === Object(prototype)) {
|
||||||
|
object.prototype = prototype;
|
||||||
|
var result = new object;
|
||||||
|
object.prototype = undefined;
|
||||||
|
}
|
||||||
|
return result || {};
|
||||||
|
};
|
||||||
|
}()));
|
||||||
|
|
||||||
setProperty(Object, '_getOwnPropertySymbols', Object.getOwnPropertySymbols);
|
setProperty(Object, '_getOwnPropertySymbols', Object.getOwnPropertySymbols);
|
||||||
setProperty(Object, 'getOwnPropertySymbols', undefined);
|
setProperty(Object, 'getOwnPropertySymbols', undefined);
|
||||||
|
|
||||||
@@ -130,6 +143,11 @@
|
|||||||
|
|
||||||
setProperty(objectProto, 'propertyIsEnumerable', objectProto._propertyIsEnumerable);
|
setProperty(objectProto, 'propertyIsEnumerable', objectProto._propertyIsEnumerable);
|
||||||
|
|
||||||
|
if (Object._create) {
|
||||||
|
Object.create = Object._create;
|
||||||
|
} else {
|
||||||
|
delete Object.create;
|
||||||
|
}
|
||||||
if (Object._getOwnPropertySymbols) {
|
if (Object._getOwnPropertySymbols) {
|
||||||
Object.getOwnPropertySymbols = Object._getOwnPropertySymbols;
|
Object.getOwnPropertySymbols = Object._getOwnPropertySymbols;
|
||||||
} else {
|
} else {
|
||||||
@@ -165,8 +183,9 @@
|
|||||||
setProperty(window, 'module', document.getElementById('module'));
|
setProperty(window, 'module', document.getElementById('module'));
|
||||||
|
|
||||||
delete funcProto._method;
|
delete funcProto._method;
|
||||||
delete objectProto._propertyIsEnumerable;
|
delete Object._create;
|
||||||
delete Object._getOwnPropertySymbols;
|
delete Object._getOwnPropertySymbols;
|
||||||
|
delete objectProto._propertyIsEnumerable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load lodash to expose it to the bad extensions/shims.
|
// Load lodash to expose it to the bad extensions/shims.
|
||||||
|
|||||||
14
test/test.js
14
test/test.js
@@ -458,7 +458,7 @@
|
|||||||
// Allow bypassing native checks.
|
// Allow bypassing native checks.
|
||||||
setProperty(funcProto, 'toString', function wrapper() {
|
setProperty(funcProto, 'toString', function wrapper() {
|
||||||
setProperty(funcProto, 'toString', fnToString);
|
setProperty(funcProto, 'toString', fnToString);
|
||||||
var result = _.has(this, 'toString') ? this.toString() : fnToString.call(this);
|
var result = lodashStable.has(this, 'toString') ? this.toString() : fnToString.call(this);
|
||||||
setProperty(funcProto, 'toString', wrapper);
|
setProperty(funcProto, 'toString', wrapper);
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
@@ -467,6 +467,17 @@
|
|||||||
funcProto._method = noop;
|
funcProto._method = noop;
|
||||||
|
|
||||||
// Set bad shims.
|
// Set bad shims.
|
||||||
|
setProperty(Object, 'create', (function() {
|
||||||
|
function object() {}
|
||||||
|
return function(prototype) {
|
||||||
|
if (lodashStable.isObject(prototype)) {
|
||||||
|
object.prototype = prototype;
|
||||||
|
var result = new object;
|
||||||
|
object.prototype = undefined;
|
||||||
|
}
|
||||||
|
return result || {};
|
||||||
|
};
|
||||||
|
}()));
|
||||||
|
|
||||||
var _getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
var _getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||||||
setProperty(Object, 'getOwnPropertySymbols', undefined);
|
setProperty(Object, 'getOwnPropertySymbols', undefined);
|
||||||
@@ -519,6 +530,7 @@
|
|||||||
root._ = oldDash;
|
root._ = oldDash;
|
||||||
|
|
||||||
// Restore built-in methods.
|
// Restore built-in methods.
|
||||||
|
setProperty(Object, 'create', create);
|
||||||
setProperty(objectProto, 'propertyIsEnumerable', _propertyIsEnumerable);
|
setProperty(objectProto, 'propertyIsEnumerable', _propertyIsEnumerable);
|
||||||
setProperty(root, 'Buffer', Buffer);
|
setProperty(root, 'Buffer', Buffer);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user