mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Simulate Safari 8's typed array constructor issue better.
This commit is contained in:
31
test/test.js
31
test/test.js
@@ -37,6 +37,7 @@
|
|||||||
document = !phantom && root.document,
|
document = !phantom && root.document,
|
||||||
body = root.document && root.document.body,
|
body = root.document && root.document.body,
|
||||||
create = Object.create,
|
create = Object.create,
|
||||||
|
fnToString = funcProto.toString,
|
||||||
freeze = Object.freeze,
|
freeze = Object.freeze,
|
||||||
hasOwnProperty = objectProto.hasOwnProperty,
|
hasOwnProperty = objectProto.hasOwnProperty,
|
||||||
JSON = root.JSON,
|
JSON = root.JSON,
|
||||||
@@ -400,8 +401,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var fnToString = funcProto.toString,
|
var nativeString = fnToString.call(toString),
|
||||||
nativeString = fnToString.call(toString),
|
|
||||||
reToString = /toString/g;
|
reToString = /toString/g;
|
||||||
|
|
||||||
function createToString(funcName) {
|
function createToString(funcName) {
|
||||||
@@ -6501,13 +6501,36 @@
|
|||||||
|
|
||||||
test('should work using its fallback', 3, function() {
|
test('should work using its fallback', 3, function() {
|
||||||
if (!isModularize) {
|
if (!isModularize) {
|
||||||
var lodash = _.runInContext(_.assign({}, root, {
|
// simulate native `Uint8Array` constructor with a `[[Class]]`
|
||||||
|
// of 'Function' and a `typeof` result of 'object'
|
||||||
|
var lodash = _.runInContext({
|
||||||
|
'Function': {
|
||||||
|
'prototype': {
|
||||||
|
'toString': function() {
|
||||||
|
return _.has(this, 'toString') ? this.toString() : fnToString.call(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'Object': _.assign(function(value) {
|
||||||
|
return Object(value);
|
||||||
|
}, {
|
||||||
|
'prototype': {
|
||||||
|
'toString': _.assign(function() {
|
||||||
|
return _.has(this, '[[Class]]') ? this['[[Class]]'] : toString.call(this);
|
||||||
|
}, {
|
||||||
|
'toString': function() {
|
||||||
|
return String(toString);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}),
|
||||||
'Uint8Array': {
|
'Uint8Array': {
|
||||||
|
'[[Class]]': funcClass,
|
||||||
'toString': function() {
|
'toString': function() {
|
||||||
return String(Uint8Array || Array);
|
return String(Uint8Array || Array);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
strictEqual(lodash.isFunction(slice), true);
|
strictEqual(lodash.isFunction(slice), true);
|
||||||
strictEqual(lodash.isFunction(/x/), false);
|
strictEqual(lodash.isFunction(/x/), false);
|
||||||
|
|||||||
Reference in New Issue
Block a user