mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Remove `looseIdentical` implementation and instead use the ES2015 `Object.is` in its place. They behave exactly the same way except for `+0`/`-0`. `looseIdentical(+0, -0)` => `true` `Object.is(+0, -0)` => `false` Other than the difference noted above, this is not be a breaking change because: 1. `looseIdentical` is a private API 2. ES2015 is listed as a mandatory polyfill in the [browser support guide](https://angular.io/guide/browser-support#mandatory-polyfills) 3. Also note that `Ivy` already uses `Object.is` in `bindingUpdated`. PR Close #37191
25 lines
859 B
TypeScript
25 lines
859 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import {areIterablesEqual, isListLikeIterable} from './iterable';
|
|
|
|
export function devModeEqual(a: any, b: any): boolean {
|
|
const isListLikeIterableA = isListLikeIterable(a);
|
|
const isListLikeIterableB = isListLikeIterable(b);
|
|
if (isListLikeIterableA && isListLikeIterableB) {
|
|
return areIterablesEqual(a, b, devModeEqual);
|
|
} else {
|
|
const isAObject = a && (typeof a === 'object' || typeof a === 'function');
|
|
const isBObject = b && (typeof b === 'object' || typeof b === 'function');
|
|
if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
|
|
return true;
|
|
} else {
|
|
return Object.is(a, b);
|
|
}
|
|
}
|
|
}
|