mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Fix Function.prototype.toString mock in test/ to avoid errors in Firefox.
This commit is contained in:
@@ -52,11 +52,18 @@
|
|||||||
Function.prototype._method = function() {};
|
Function.prototype._method = function() {};
|
||||||
|
|
||||||
// allow bypassing native checks
|
// allow bypassing native checks
|
||||||
var _toString = Function.prototype.toString;
|
var _fnToString = Function.prototype.toString;
|
||||||
setProperty(Function.prototype, '_toString', _toString);
|
setProperty(Function.prototype, '_toString', _fnToString);
|
||||||
setProperty(Function.prototype, 'toString', function() {
|
|
||||||
return this === Set ? this.toString() : _toString.call(this);
|
setProperty(Function.prototype, 'toString', (function() {
|
||||||
});
|
function fnToString() {
|
||||||
|
setProperty(Function.prototype, 'toString', _fnToString);
|
||||||
|
var result = this === Set ? this.toString() : _fnToString.call(this);
|
||||||
|
setProperty(Function.prototype, 'toString', fnToString);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return fnToString;
|
||||||
|
}()));
|
||||||
|
|
||||||
// set bad shims
|
// set bad shims
|
||||||
setProperty(Array, '_isArray', Array.isArray);
|
setProperty(Array, '_isArray', Array.isArray);
|
||||||
@@ -198,7 +205,7 @@
|
|||||||
var reBasename = /[\w.-]+$/,
|
var reBasename = /[\w.-]+$/,
|
||||||
basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''),
|
basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''),
|
||||||
modulePath = ui.buildPath.replace(/\.js$/, ''),
|
modulePath = ui.buildPath.replace(/\.js$/, ''),
|
||||||
locationPath = modulePath.replace(reBasename, ''),
|
locationPath = modulePath.replace(reBasename, '').replace(/\/$/, ''),
|
||||||
moduleMain = modulePath.match(reBasename)[0],
|
moduleMain = modulePath.match(reBasename)[0],
|
||||||
uid = +new Date;
|
uid = +new Date;
|
||||||
|
|
||||||
@@ -227,7 +234,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
'location': basePath + '/test',
|
'location': basePath + 'test',
|
||||||
'main': 'test',
|
'main': 'test',
|
||||||
'config': {
|
'config': {
|
||||||
// work around no global being exported
|
// work around no global being exported
|
||||||
|
|||||||
16
test/test.js
16
test/test.js
@@ -272,10 +272,16 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// allow bypassing native checks
|
// allow bypassing native checks
|
||||||
var _toString = Function.prototype.toString;
|
var _fnToString = Function.prototype.toString;
|
||||||
setProperty(Function.prototype, 'toString', function() {
|
setProperty(Function.prototype, 'toString', (function() {
|
||||||
return this === Set ? this.toString() : _toString.call(this);
|
function fnToString() {
|
||||||
});
|
setProperty(Function.prototype, 'toString', _fnToString);
|
||||||
|
var result = this === Set ? this.toString() : _fnToString.call(this);
|
||||||
|
setProperty(Function.prototype, 'toString', fnToString);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return fnToString;
|
||||||
|
}()));
|
||||||
|
|
||||||
// add extensions
|
// add extensions
|
||||||
Function.prototype._method = function() {};
|
Function.prototype._method = function() {};
|
||||||
@@ -325,7 +331,7 @@
|
|||||||
setProperty(Object, 'getPrototypeOf', _getPrototypeOf);
|
setProperty(Object, 'getPrototypeOf', _getPrototypeOf);
|
||||||
setProperty(Object, 'keys', _keys);
|
setProperty(Object, 'keys', _keys);
|
||||||
|
|
||||||
setProperty(Function.prototype, 'toString', _toString);
|
setProperty(Function.prototype, 'toString', _fnToString);
|
||||||
|
|
||||||
_.forOwn({
|
_.forOwn({
|
||||||
'contains': _contains,
|
'contains': _contains,
|
||||||
|
|||||||
Reference in New Issue
Block a user