@@ -361,24 +361,27 @@ exports.valObjectMeta = {
361
361
* as a convenience, returns the value it finally set
362
362
*/
363
363
exports . coerce = function ( containerIn , containerOut , attributes , attribute , dflt ) {
364
- return _coerce ( containerIn , containerOut , attributes , attribute , dflt ) . value ;
364
+ return _coerce ( containerIn , containerOut , attributes , attribute , dflt ) . val ;
365
365
} ;
366
366
367
367
function _coerce ( containerIn , containerOut , attributes , attribute , dflt ) {
368
368
var opts = nestedProperty ( attributes , attribute ) . get ( ) ;
369
+ if ( dflt === undefined ) dflt = opts . dflt ;
370
+ var src = '' ; // i.e. default
371
+
369
372
var propIn = nestedProperty ( containerIn , attribute ) ;
370
373
var propOut = nestedProperty ( containerOut , attribute ) ;
371
374
var valIn = propIn . get ( ) ;
372
375
373
376
var template = containerOut . _template ;
374
377
if ( valIn === undefined && template ) {
375
378
valIn = nestedProperty ( template , attribute ) . get ( ) ;
379
+ if ( valIn !== undefined ) src = 't' ; // template
380
+
376
381
// already used the template value, so short-circuit the second check
377
382
template = 0 ;
378
383
}
379
384
380
- if ( dflt === undefined ) dflt = opts . dflt ;
381
-
382
385
/**
383
386
* arrayOk: value MAY be an array, then we do no value checking
384
387
* at this point, because it can be more complicated than the
@@ -388,25 +391,32 @@ function _coerce(containerIn, containerOut, attributes, attribute, dflt) {
388
391
if ( opts . arrayOk && isArrayOrTypedArray ( valIn ) ) {
389
392
propOut . set ( valIn ) ;
390
393
return {
391
- value : valIn ,
392
- default : dflt
394
+ inp : valIn ,
395
+ val : valIn ,
396
+ src : 'c' // container
393
397
} ;
394
398
}
395
399
396
400
var coerceFunction = exports . valObjectMeta [ opts . valType ] . coerceFunction ;
397
401
coerceFunction ( valIn , propOut , dflt , opts ) ;
398
402
399
403
var valOut = propOut . get ( ) ;
404
+ if ( valOut !== undefined ) src = 'c' ; // container
405
+
400
406
// in case v was provided but invalid, try the template again so it still
401
407
// overrides the regular default
402
408
if ( template && valOut === dflt && ! validate ( valIn , opts ) ) {
403
409
valIn = nestedProperty ( template , attribute ) . get ( ) ;
404
410
coerceFunction ( valIn , propOut , dflt , opts ) ;
405
411
valOut = propOut . get ( ) ;
412
+
413
+ if ( valOut !== undefined ) src = 't' ; // template
406
414
}
415
+
407
416
return {
408
- value : valOut ,
409
- default : dflt
417
+ inp : valIn ,
418
+ val : valOut ,
419
+ src : src
410
420
} ;
411
421
}
412
422
@@ -419,16 +429,7 @@ function _coerce(containerIn, containerOut, attributes, attribute, dflt) {
419
429
*/
420
430
exports . coerce2 = function ( containerIn , containerOut , attributes , attribute , dflt ) {
421
431
var out = _coerce ( containerIn , containerOut , attributes , attribute , dflt ) ;
422
- var valOut = out . value ;
423
- if (
424
- valOut !== undefined &&
425
- valOut !== out . default
426
- ) {
427
- return valOut ;
428
- }
429
-
430
- var valIn = nestedProperty ( containerIn , attribute ) . get ( ) ;
431
- return ( valIn !== undefined && valIn !== null ) ? valOut : false ;
432
+ return ( out . src && out . inp !== undefined ) ? out . val : false ;
432
433
} ;
433
434
434
435
/*
0 commit comments