This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -1087,20 +1087,20 @@ function $ParseProvider() {
1087
1087
if ( o1 == null || o2 == null ) return o1 === o2 ; // null/undefined
1088
1088
1089
1089
if ( typeof o1 === "object" ) {
1090
- // The same object is not supported because it may have been mutated
1091
- if ( o1 === o2 ) return false ;
1092
1090
1093
- if ( typeof o2 !== "object" ) return false ;
1091
+ // attempt to convert the value to a primitive type
1092
+ // TODO(docs): add a note to docs that by implementing valueOf even objects and arrays can
1093
+ // be cheaply dirty-checked
1094
+ o1 = o1 . valueOf ( ) ;
1094
1095
1095
- // Dates
1096
- if ( isDate ( o1 ) && isDate ( o2 ) ) { // TODO(perf): make this more generic via valueOf
1097
- o1 = o1 . getTime ( ) ;
1098
- o2 = o2 . getTime ( ) ;
1099
- // Fallthru to the primitive equality check
1100
- } else {
1096
+ if ( typeof o1 === "object" ) {
1101
1097
// objects/arrays are not supported - deep-watching them would be too expensive
1102
1098
return false ;
1103
1099
}
1100
+
1101
+ o2 = o2 . valueOf ( ) ;
1102
+
1103
+ // fall-through to the primitive equality check
1104
1104
}
1105
1105
1106
1106
//Primitive or NaN
You can’t perform that action at this time.
0 commit comments