@@ -361,6 +361,10 @@ 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 ;
365
+ } ;
366
+
367
+ function _coerce ( containerIn , containerOut , attributes , attribute , dflt ) {
364
368
var opts = nestedProperty ( attributes , attribute ) . get ( ) ;
365
369
var propIn = nestedProperty ( containerIn , attribute ) ;
366
370
var propOut = nestedProperty ( containerOut , attribute ) ;
@@ -383,7 +387,10 @@ exports.coerce = function(containerIn, containerOut, attributes, attribute, dflt
383
387
*/
384
388
if ( opts . arrayOk && isArrayOrTypedArray ( valIn ) ) {
385
389
propOut . set ( valIn ) ;
386
- return valIn ;
390
+ return {
391
+ value : valIn ,
392
+ default : dflt
393
+ } ;
387
394
}
388
395
389
396
var coerceFunction = exports . valObjectMeta [ opts . valType ] . coerceFunction ;
@@ -397,8 +404,11 @@ exports.coerce = function(containerIn, containerOut, attributes, attribute, dflt
397
404
coerceFunction ( valIn , propOut , dflt , opts ) ;
398
405
valOut = propOut . get ( ) ;
399
406
}
400
- return valOut ;
401
- } ;
407
+ return {
408
+ value : valOut ,
409
+ default : dflt
410
+ } ;
411
+ }
402
412
403
413
/**
404
414
* Variation on coerce
@@ -408,11 +418,11 @@ exports.coerce = function(containerIn, containerOut, attributes, attribute, dflt
408
418
* returns false if there is no user input.
409
419
*/
410
420
exports . coerce2 = function ( containerIn , containerOut , attributes , attribute , dflt ) {
411
- var valOut = exports . coerce ( containerIn , containerOut , attributes , attribute , dflt ) ;
412
-
413
- var attr = attributes [ attribute ] ;
414
- var theDefault = ( dflt !== undefined ) ? dflt : ( attr || { } ) . dflt ;
421
+ var out = _coerce ( containerIn , containerOut , attributes , attribute , dflt ) ;
422
+ var valOut = out . value ;
423
+ var theDefault = out . default ;
415
424
if (
425
+ valOut !== undefined &&
416
426
theDefault !== undefined &&
417
427
theDefault !== valOut
418
428
) {
0 commit comments