GeezerVison is showing github.com — perf(forms): use `ngDevMode` to tree-shake `_ngModelWarning` (#39964) · angular/angular@735556d
File treeExpand file treeCollapse file tree Open diff view settings packages/forms/src/directives
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/forms/src/directives/reactive_directives/form_control_directive.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -125,7 +125,9 @@ export class FormControlDirective extends NgControl implements OnChanges { | 125 | 125 | this.form.updateValueAndValidity({emitEvent: false}); | 126 | 126 | } | 127 | 127 | if (isPropertyUpdated(changes, this.viewModel)) { | 128 | | - _ngModelWarning('formControl', FormControlDirective, this, this._ngModelWarningConfig); | | 128 | + if (typeof ngDevMode === 'undefined' || ngDevMode) { | | 129 | + _ngModelWarning('formControl', FormControlDirective, this, this._ngModelWarningConfig); | | 130 | + } | 129 | 131 | this.form.setValue(this.model); | 130 | 132 | this.viewModel = this.model; | 131 | 133 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/forms/src/directives/reactive_directives/form_control_name.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -145,7 +145,9 @@ export class FormControlName extends NgControl implements OnChanges, OnDestroy { | 145 | 145 | ngOnChanges(changes: SimpleChanges) { | 146 | 146 | if (!this._added) this._setUpControl(); | 147 | 147 | if (isPropertyUpdated(changes, this.viewModel)) { | 148 | | - _ngModelWarning('formControlName', FormControlName, this, this._ngModelWarningConfig); | | 148 | + if (typeof ngDevMode === 'undefined' || ngDevMode) { | | 149 | + _ngModelWarning('formControlName', FormControlName, this, this._ngModelWarningConfig); | | 150 | + } | 149 | 151 | this.viewModel = this.model; | 150 | 152 | this.formDirective.updateModel(this, this.model); | 151 | 153 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/forms/src/directives/shared.ts +2-6Lines changed: 2 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | * found in the LICENSE file at https://angular.io/license | 7 | 7 | */ | 8 | 8 |
| 9 | | -import {isDevMode} from '@angular/core'; | 10 | | - | 11 | 9 | import {AbstractControl, FormArray, FormControl, FormGroup} from '../model'; | 12 | 10 | import {getControlAsyncValidators, getControlValidators, mergeValidators} from '../validators'; | 13 | 11 |
| @@ -324,13 +322,11 @@ export function removeListItem<T>(list: T[], el: T): void { | 324 | 322 | export function _ngModelWarning( | 325 | 323 | name: string, type: {_ngModelWarningSentOnce: boolean}, | 326 | 324 | instance: {_ngModelWarningSent: boolean}, warningConfig: string|null) { | 327 | | - if (!isDevMode() || warningConfig === 'never') return; | | 325 | + if (warningConfig === 'never') return; | 328 | 326 |
| 329 | 327 | if (((warningConfig === null || warningConfig === 'once') && !type._ngModelWarningSentOnce) || | 330 | 328 | (warningConfig === 'always' && !instance._ngModelWarningSent)) { | 331 | | - if (typeof ngDevMode === 'undefined' || ngDevMode) { | 332 | | - ReactiveErrors.ngModelWarning(name); | 333 | | - } | | 329 | + ReactiveErrors.ngModelWarning(name); | 334 | 330 | type._ngModelWarningSentOnce = true; | 335 | 331 | instance._ngModelWarningSent = true; | 336 | 332 | } | |
|