reverting some changes to isEqual that were a little too aggressive

This commit is contained in:
Michael Ficarra
2011-09-04 19:34:19 -04:00
parent c7c57ca6ff
commit bf3aa97c36
2 changed files with 12 additions and 9 deletions

View File

@@ -610,10 +610,12 @@
// `NaN` values are equal. // `NaN` values are equal.
if (_.isNaN(a)) return _.isNaN(b); if (_.isNaN(a)) return _.isNaN(b);
// Compare dates by their millisecond values. // Compare dates by their millisecond values.
if (_.isDate(a)) return _.isDate(b) && a.getTime() == b.getTime(); var isDateA = _.isDate(a), isDateB = _.isDate(b);
if (isDateA || isDateB) return isDateA && isDateB && a.getTime() == b.getTime();
// Compare RegExps by their source patterns and flags. // Compare RegExps by their source patterns and flags.
if (_.isRegExp(a)) var isRegExpA = _.isRegExp(a), isRegExpB = _.isRegExp(b);
return _.isRegExp(b) && if (isRegExpA || isRegExpB)
return isRegExpA && isRegExpB &&
a.source == b.source && a.source == b.source &&
a.global == b.global && a.global == b.global &&
a.multiline == b.multiline && a.multiline == b.multiline &&
@@ -625,6 +627,7 @@
if (b._chain) b = b._wrapped; if (b._chain) b = b._wrapped;
// Invoke a custom `isEqual` method if one is provided. // Invoke a custom `isEqual` method if one is provided.
if (typeof a.isEqual == 'function') return a.isEqual(b); if (typeof a.isEqual == 'function') return a.isEqual(b);
if (typeof b.isEqual == 'function') return b.isEqual(a);
// Compare array lengths to determine if a deep comparison is necessary. // Compare array lengths to determine if a deep comparison is necessary.
if ('length' in a && (a.length !== b.length)) return false; if ('length' in a && (a.length !== b.length)) return false;
// Assume equality for cyclic structures. // Assume equality for cyclic structures.