Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function _prepareInstance( modelStr, defaults ) {
let model;
let init;
let existingInstance = null;
for ( const path in defaults ) {
if ( Object.prototype.hasOwnProperty.call( defaults, path ) ) {
model = model || new FormModel( modelStr, {
full: false
} );
init = init || model.init();
if ( Object.prototype.hasOwnProperty.call( defaults, path ) ) {
// if this fails, the FormModel will output a console error and ignore the instruction
model.node( path ).setVal( defaults[ path ] );
}
// TODO would be good to not include nodes that weren't in the defaults parameter
// HOWEVER, that would also set number of repeats to 0, which may be undesired
// TODO would be good to just pass model along instead of converting to string first
existingInstance = model.getStr();
}
}
return existingInstance;
}