1- import {
2- toObservable ,
3- isEvent ,
4- getHandler ,
5- isReactNative
6- } from './utils'
1+ import { toObservable , isEvent , getHandler , isReactNative } from './utils'
72import Subject from './observable'
83import Validators from './validators'
94
@@ -116,36 +111,36 @@ function normalizeAsyncValidator(validator) {
116111 * @return {Function|null }
117112 */
118113function composeValidators ( validators ) {
119- return validators != null ?
120- Validators . compose ( validators . map ( normalizeValidator ) ) :
121- null
114+ return validators != null
115+ ? Validators . compose ( validators . map ( normalizeValidator ) )
116+ : null
122117}
123118/**
124119 * @param {Function[] } validators
125120 * @return {Function|null }
126121 */
127122function composeAsyncValidators ( validators ) {
128- return validators != null ?
129- Validators . composeAsync ( validators . map ( normalizeAsyncValidator ) ) :
130- null
123+ return validators != null
124+ ? Validators . composeAsync ( validators . map ( normalizeAsyncValidator ) )
125+ : null
131126}
132127
133128function coerceToValidator ( validatorOrOpts ) {
134- const validator = isOptionsObj ( validatorOrOpts ) ?
135- validatorOrOpts . validators :
136- validatorOrOpts
137- return Array . isArray ( validator ) ?
138- composeValidators ( validator ) :
139- validator || null
129+ const validator = isOptionsObj ( validatorOrOpts )
130+ ? validatorOrOpts . validators
131+ : validatorOrOpts
132+ return Array . isArray ( validator )
133+ ? composeValidators ( validator )
134+ : validator || null
140135}
141136
142137function coerceToAsyncValidator ( asyncValidator , validatorOrOpts ) {
143- const origAsyncValidator = isOptionsObj ( validatorOrOpts ) ?
144- validatorOrOpts . asyncValidators :
145- asyncValidator
146- return Array . isArray ( origAsyncValidator ) ?
147- composeAsyncValidators ( origAsyncValidator ) :
148- origAsyncValidator || null
138+ const origAsyncValidator = isOptionsObj ( validatorOrOpts )
139+ ? validatorOrOpts . asyncValidators
140+ : asyncValidator
141+ return Array . isArray ( origAsyncValidator )
142+ ? composeAsyncValidators ( origAsyncValidator )
143+ : origAsyncValidator || null
149144}
150145/**
151146 * This is the base class for `FormControl`, `FormGroup`, and
@@ -179,7 +174,7 @@ export class AbstractControl {
179174 * *not* mark it dirty.
180175 */
181176 this . pristine = true
182- this . meta = { }
177+ this . meta = { }
183178 this . _pendingChange = this . updateOn !== 'change'
184179 this . _pendingDirty = false
185180 this . _pendingTouched = false
@@ -197,9 +192,11 @@ export class AbstractControl {
197192 * Possible values: `'change'` (default) | `'blur'` | `'submit'`
198193 */
199194 get updateOn ( ) {
200- return this . _updateOn ?
201- this . _updateOn :
202- this . parent ? this . parent . updateOn : 'change'
195+ return this . _updateOn
196+ ? this . _updateOn
197+ : this . parent
198+ ? this . parent . updateOn
199+ : 'change'
203200 }
204201 /**
205202 * A control is `dirty` if the user has changed the value
@@ -373,14 +370,17 @@ export class AbstractControl {
373370 *
374371 * This will also mark all direct ancestors as `touched` to maintain
375372 * the model.
376- * @param {{onlySelf: Boolean} } opts
373+ * @param {{onlySelf: Boolean, emitEvent: Boolean } } opts
377374 * @return {void }
378375 */
379376 markAsTouched ( opts = { } ) {
380377 this . touched = true
381378 if ( this . _parent && ! opts . onlySelf ) {
382379 this . _parent . markAsTouched ( opts )
383380 }
381+ if ( opts . emitEvent ) {
382+ this . stateChanges . next ( )
383+ }
384384 }
385385 /**
386386 * Marks the control as `submitted`.
@@ -448,7 +448,7 @@ export class AbstractControl {
448448 * If the control has any children, it will also mark all children as `untouched`
449449 * to maintain the model, and re-calculate the `touched` status of all parent
450450 * controls.
451- * @param {{onlySelf: Boolean} } opts
451+ * @param {{onlySelf: Boolean, emitEvent: Boolean } } opts
452452 * @return {void }
453453 */
454454 markAsUntouched ( opts = { } ) {
@@ -462,6 +462,9 @@ export class AbstractControl {
462462 if ( this . _parent && ! opts . onlySelf ) {
463463 this . _parent . _updateTouched ( opts )
464464 }
465+ if ( opts . emitEvent ) {
466+ this . stateChanges . next ( )
467+ }
465468 }
466469 /**
467470 * Marks the control as `dirty`.
@@ -1332,9 +1335,9 @@ export class FormArray extends AbstractControl {
13321335 */
13331336 getRawValue ( ) {
13341337 return this . controls . map ( control => {
1335- return control instanceof FormControl ?
1336- control . value :
1337- control . getRawValue ( )
1338+ return control instanceof FormControl
1339+ ? control . value
1340+ : control . getRawValue ( )
13381341 } )
13391342 }
13401343
@@ -1398,4 +1401,4 @@ export class FormArray extends AbstractControl {
13981401 }
13991402
14001403 _onCollectionChange ( ) { }
1401- }
1404+ }
0 commit comments