@@ -361,24 +361,27 @@ exports.valObjectMeta = {
361361 * as a convenience, returns the value it finally set
362362 */
363363exports . 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 ;
365365} ;
366366
367367function _coerce ( containerIn , containerOut , attributes , attribute , dflt ) {
368368 var opts = nestedProperty ( attributes , attribute ) . get ( ) ;
369+ if ( dflt === undefined ) dflt = opts . dflt ;
370+ var src = '' ; // i.e. default
371+
369372 var propIn = nestedProperty ( containerIn , attribute ) ;
370373 var propOut = nestedProperty ( containerOut , attribute ) ;
371374 var valIn = propIn . get ( ) ;
372375
373376 var template = containerOut . _template ;
374377 if ( valIn === undefined && template ) {
375378 valIn = nestedProperty ( template , attribute ) . get ( ) ;
379+ if ( valIn !== undefined ) src = 't' ; // template
380+
376381 // already used the template value, so short-circuit the second check
377382 template = 0 ;
378383 }
379384
380- if ( dflt === undefined ) dflt = opts . dflt ;
381-
382385 /**
383386 * arrayOk: value MAY be an array, then we do no value checking
384387 * at this point, because it can be more complicated than the
@@ -388,25 +391,32 @@ function _coerce(containerIn, containerOut, attributes, attribute, dflt) {
388391 if ( opts . arrayOk && isArrayOrTypedArray ( valIn ) ) {
389392 propOut . set ( valIn ) ;
390393 return {
391- value : valIn ,
392- default : dflt
394+ inp : valIn ,
395+ val : valIn ,
396+ src : 'c' // container
393397 } ;
394398 }
395399
396400 var coerceFunction = exports . valObjectMeta [ opts . valType ] . coerceFunction ;
397401 coerceFunction ( valIn , propOut , dflt , opts ) ;
398402
399403 var valOut = propOut . get ( ) ;
404+ if ( valOut !== undefined ) src = 'c' ; // container
405+
400406 // in case v was provided but invalid, try the template again so it still
401407 // overrides the regular default
402408 if ( template && valOut === dflt && ! validate ( valIn , opts ) ) {
403409 valIn = nestedProperty ( template , attribute ) . get ( ) ;
404410 coerceFunction ( valIn , propOut , dflt , opts ) ;
405411 valOut = propOut . get ( ) ;
412+
413+ if ( valOut !== undefined ) src = 't' ; // template
406414 }
415+
407416 return {
408- value : valOut ,
409- default : dflt
417+ inp : valIn ,
418+ val : valOut ,
419+ src : src
410420 } ;
411421}
412422
@@ -419,16 +429,7 @@ function _coerce(containerIn, containerOut, attributes, attribute, dflt) {
419429 */
420430exports . coerce2 = function ( containerIn , containerOut , attributes , attribute , dflt ) {
421431 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 ;
432433} ;
433434
434435/*
0 commit comments