refactor(core): remove looseIdentical
in favor of built-in Object.is
(#37191)
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
This commit is contained in:

committed by
Matias Niemelä

parent
3e68029522
commit
ba0faa2f77
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Directive, ElementRef, forwardRef, Host, Input, OnDestroy, Optional, Renderer2, StaticProvider, ɵlooseIdentical as looseIdentical} from '@angular/core';
|
||||
import {Directive, ElementRef, forwardRef, Host, Input, OnDestroy, Optional, Renderer2, StaticProvider} from '@angular/core';
|
||||
|
||||
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
||||
|
||||
@ -121,7 +121,7 @@ export class SelectControlValueAccessor implements ControlValueAccessor {
|
||||
this._compareWith = fn;
|
||||
}
|
||||
|
||||
private _compareWith: (o1: any, o2: any) => boolean = looseIdentical;
|
||||
private _compareWith: (o1: any, o2: any) => boolean = Object.is;
|
||||
|
||||
constructor(private _renderer: Renderer2, private _elementRef: ElementRef) {}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Directive, ElementRef, forwardRef, Host, Input, OnDestroy, Optional, Renderer2, StaticProvider, ɵlooseIdentical as looseIdentical} from '@angular/core';
|
||||
import {Directive, ElementRef, forwardRef, Host, Input, OnDestroy, Optional, Renderer2, StaticProvider} from '@angular/core';
|
||||
|
||||
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
||||
|
||||
@ -118,7 +118,7 @@ export class SelectMultipleControlValueAccessor implements ControlValueAccessor
|
||||
this._compareWith = fn;
|
||||
}
|
||||
|
||||
private _compareWith: (o1: any, o2: any) => boolean = looseIdentical;
|
||||
private _compareWith: (o1: any, o2: any) => boolean = Object.is;
|
||||
|
||||
constructor(private _renderer: Renderer2, private _elementRef: ElementRef) {}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {isDevMode, ɵlooseIdentical as looseIdentical} from '@angular/core';
|
||||
import {isDevMode} from '@angular/core';
|
||||
|
||||
import {FormArray, FormControl, FormGroup} from '../model';
|
||||
import {Validators} from '../validators';
|
||||
@ -156,7 +156,7 @@ export function isPropertyUpdated(changes: {[key: string]: any}, viewModel: any)
|
||||
const change = changes['model'];
|
||||
|
||||
if (change.isFirstChange()) return true;
|
||||
return !looseIdentical(viewModel, change.currentValue);
|
||||
return !Object.is(viewModel, change.currentValue);
|
||||
}
|
||||
|
||||
const BUILTIN_ACCESSORS = [
|
||||
|
Reference in New Issue
Block a user