Skip to content

Commit 24d1da9

Browse files
committedJun 17, 2020
remove unnecessary validation, also
- use false and true values for src - reduce if statements
1 parent adc36cd commit 24d1da9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎src/lib/coerce.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ function _coerce(containerIn, containerOut, attributes, attribute, dflt, opts) {
369369

370370
var attr = nestedProperty(attributes, attribute).get();
371371
if(dflt === undefined) dflt = attr.dflt;
372-
var src = ''; // i.e. default
372+
var src = false;
373373

374374
var propIn = nestedProperty(containerIn, attribute);
375375
var propOut = nestedProperty(containerOut, attribute);
@@ -378,7 +378,7 @@ function _coerce(containerIn, containerOut, attributes, attribute, dflt, opts) {
378378
var template = containerOut._template;
379379
if(valIn === undefined && template) {
380380
valIn = nestedProperty(template, attribute).get();
381-
if(valIn !== undefined && shouldValidate && validate(valIn, attr)) src = 't'; // template
381+
src = (valIn !== undefined);
382382

383383
// already used the template value, so short-circuit the second check
384384
template = 0;
@@ -395,15 +395,15 @@ function _coerce(containerIn, containerOut, attributes, attribute, dflt, opts) {
395395
return {
396396
inp: valIn,
397397
val: valIn,
398-
src: 'c' // container
398+
src: true
399399
};
400400
}
401401

402402
var coerceFunction = exports.valObjectMeta[attr.valType].coerceFunction;
403403
coerceFunction(valIn, propOut, dflt, attr);
404404

405405
var valOut = propOut.get();
406-
if(valOut !== undefined && shouldValidate && validate(valIn, attr)) src = 'c'; // container
406+
src = (valOut !== undefined) && shouldValidate && validate(valIn, attr);
407407

408408
// in case v was provided but invalid, try the template again so it still
409409
// overrides the regular default
@@ -412,7 +412,7 @@ function _coerce(containerIn, containerOut, attributes, attribute, dflt, opts) {
412412
coerceFunction(valIn, propOut, dflt, attr);
413413
valOut = propOut.get();
414414

415-
if(valOut !== undefined && shouldValidate && validate(valIn, attr)) src = 't'; // template
415+
src = (valOut !== undefined) && shouldValidate && validate(valIn, attr);
416416
}
417417

418418
return {

0 commit comments

Comments
 (0)
Please sign in to comment.