mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Cleanup error object fork in baseIsEqual.
This commit is contained in:
35
lodash.js
35
lodash.js
@@ -1964,28 +1964,31 @@
|
|||||||
valIsArg = isArguments(value);
|
valIsArg = isArguments(value);
|
||||||
othIsArg = isArguments(other);
|
othIsArg = isArguments(other);
|
||||||
}
|
}
|
||||||
var hasValCtor = !valIsArg && hasOwnProperty.call(value, 'constructor'),
|
// in older versions of Opera, `arguments` objects have `Array` constructors
|
||||||
hasOthCtor = !othIsArg && hasOwnProperty.call(other, 'constructor');
|
var valCtor = valIsArg ? Object : value.constructor,
|
||||||
|
othCtor = othIsArg ? Object : other.constructor;
|
||||||
if (hasValCtor != hasOthCtor) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!hasValCtor) {
|
|
||||||
// in older versions of Opera, `arguments` objects have `Array` constructors
|
|
||||||
var valCtor = valIsArg ? Object : value.constructor,
|
|
||||||
othCtor = othIsArg ? Object : other.constructor;
|
|
||||||
|
|
||||||
|
if (isErr) {
|
||||||
// error objects of different types are not equal
|
// error objects of different types are not equal
|
||||||
if (isErr && valCtor.prototype.name != othCtor.prototype.name) {
|
if (valCtor.prototype.name != othCtor.prototype.name) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// non `Object` object instances with different constructors are not equal
|
} else {
|
||||||
if (valCtor != othCtor &&
|
var valHasCtor = !valIsArg && hasOwnProperty.call(value, 'constructor'),
|
||||||
!(isFunction(valCtor) && valCtor instanceof valCtor && isFunction(othCtor) && othCtor instanceof othCtor) &&
|
othHasCtor = !othIsArg && hasOwnProperty.call(other, 'constructor');
|
||||||
('constructor' in value && 'constructor' in other)
|
|
||||||
) {
|
if (valHasCtor != othHasCtor) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!valHasCtor) {
|
||||||
|
// non `Object` object instances with different constructors are not equal
|
||||||
|
if (valCtor != othCtor &&
|
||||||
|
!(isFunction(valCtor) && valCtor instanceof valCtor && isFunction(othCtor) && othCtor instanceof othCtor) &&
|
||||||
|
('constructor' in value && 'constructor' in other)
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var valProps = isErr ? ['message', 'name'] : keys(value),
|
var valProps = isErr ? ['message', 'name'] : keys(value),
|
||||||
othProps = isErr ? valProps : keys(other);
|
othProps = isErr ? valProps : keys(other);
|
||||||
|
|||||||
Reference in New Issue
Block a user