mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Fix test fails in older Safari and cleanup setProperty in test.js.
This commit is contained in:
@@ -20,31 +20,21 @@
|
||||
<div id="exports"></div>
|
||||
<script>
|
||||
var setProperty = (function() {
|
||||
var defineProperty = (function() {
|
||||
try {
|
||||
var o = {},
|
||||
func = Object.defineProperty,
|
||||
result = func(o, o, o) && func;
|
||||
} catch(e) { }
|
||||
return result;
|
||||
}());
|
||||
|
||||
if (!defineProperty) {
|
||||
return function(object, key, value) {
|
||||
object[key] = value;
|
||||
};
|
||||
}
|
||||
var _defineProperty = Object.defineProperty;
|
||||
return function(object, key, value) {
|
||||
// avoid a bug where overwriting non-enumerable built-ins makes them enumerable
|
||||
// https://code.google.com/p/v8/issues/detail?id=1623
|
||||
defineProperty(object, key, {
|
||||
'configurable': true,
|
||||
'enumerable': false,
|
||||
'writable': true,
|
||||
'value': value
|
||||
});
|
||||
|
||||
}
|
||||
try {
|
||||
_defineProperty(object, key, {
|
||||
'configurable': true,
|
||||
'enumerable': false,
|
||||
'writable': true,
|
||||
'value': value
|
||||
});
|
||||
} catch(e) {
|
||||
object[key] = value;
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
||||
function addBizarroMethods() {
|
||||
@@ -52,9 +42,6 @@
|
||||
Function.prototype._method = function() {};
|
||||
|
||||
// allow bypassing native checks
|
||||
var _fnToString = Function.prototype.toString;
|
||||
setProperty(Function.prototype, '_toString', _fnToString);
|
||||
|
||||
setProperty(Function.prototype, 'toString', (function() {
|
||||
function fnToString() {
|
||||
setProperty(Function.prototype, 'toString', _fnToString);
|
||||
@@ -62,6 +49,8 @@
|
||||
setProperty(Function.prototype, 'toString', fnToString);
|
||||
return result;
|
||||
}
|
||||
var _fnToString = Function.prototype.toString;
|
||||
setProperty(Function.prototype, '_toString', _fnToString);
|
||||
return fnToString;
|
||||
}()));
|
||||
|
||||
|
||||
19
test/test.js
19
test/test.js
@@ -213,23 +213,20 @@
|
||||
* @param {string} key The name of the property to set.
|
||||
* @param {*} value The property value.
|
||||
*/
|
||||
var setProperty = (function() {
|
||||
if (!defineProperty) {
|
||||
return function(object, key, value) {
|
||||
object[key] = value;
|
||||
};
|
||||
}
|
||||
return function(object, key, value) {
|
||||
// avoid a bug where overwriting non-enumerable built-ins makes them enumerable
|
||||
// https://code.google.com/p/v8/issues/detail?id=1623
|
||||
function setProperty(object, key, value) {
|
||||
// avoid a bug where overwriting non-enumerable built-ins makes them enumerable
|
||||
// https://code.google.com/p/v8/issues/detail?id=1623
|
||||
try {
|
||||
defineProperty(object, key, {
|
||||
'configurable': true,
|
||||
'enumerable': false,
|
||||
'writable': true,
|
||||
'value': value
|
||||
});
|
||||
};
|
||||
}());
|
||||
} catch(e) {
|
||||
object[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips a given number of tests with a passing result.
|
||||
|
||||
3
vendor/qunit-extras/qunit-extras.js
vendored
3
vendor/qunit-extras/qunit-extras.js
vendored
@@ -331,13 +331,14 @@
|
||||
config = QUnit.config,
|
||||
index = -1,
|
||||
length = asserts.length,
|
||||
logs = config.extrasData.logs,
|
||||
queue = config.queue;
|
||||
|
||||
while (++index < length) {
|
||||
var assert = asserts[index];
|
||||
if (!assert.result && this.retries < config.asyncRetries) {
|
||||
this.retries++;
|
||||
config.extrasData.logs.length -= asserts.length;
|
||||
logs.length = Math.max(0, logs.length - asserts.length);
|
||||
asserts.length = 0;
|
||||
|
||||
var oldLength = queue.length;
|
||||
|
||||
Reference in New Issue
Block a user