Ensure all params are numeric
This has long been a curse, and I don't know why I didn't resolve it sooner. This makes explicit some of the odd things that this is doing, to maintain the previous behavior. Changing that behavior would be ideal, but ought to be done separately and put behind a feature flag.master
parent
250c230d94
commit
5a816a4701
|
@ -252,9 +252,9 @@
|
||||||
<value-of select="@type" />
|
<value-of select="@type" />
|
||||||
<text>',</text>
|
<text>',</text>
|
||||||
|
|
||||||
<text>'default': '</text>
|
<text>'default':</text>
|
||||||
<value-of select="@default" />
|
<value-of select="if ( @default ) then number(@default) else '0'" />
|
||||||
<text>',</text>
|
<text>,</text>
|
||||||
|
|
||||||
<text>depth: </text>
|
<text>depth: </text>
|
||||||
<!-- TODO: this logic is duplicated multiple places -->
|
<!-- TODO: this logic is duplicated multiple places -->
|
||||||
|
@ -1776,21 +1776,26 @@
|
||||||
// scalar
|
// scalar
|
||||||
if ( depth === 0 )
|
if ( depth === 0 )
|
||||||
{
|
{
|
||||||
return ( input === '' || input === undefined ) ? value : input;
|
// TODO: error
|
||||||
|
if ( Array.isArray( input ) ) input = input[0];
|
||||||
|
return ( input === '' || input === undefined ) ? value : +input;
|
||||||
}
|
}
|
||||||
|
|
||||||
input = input || [];
|
// TODO: error for both
|
||||||
|
if (!Array.isArray(input)) input = [input];
|
||||||
|
if (depth === 1 && Array.isArray(input[0])) input = input[0];
|
||||||
|
|
||||||
// vector or matrix
|
// TODO: this maintains old behavior, but maybe should be an error;
|
||||||
var i = input.length || 1;
|
// we cannot have empty index sets (see design/tpl).
|
||||||
var ret = [];
|
if (input.length === 0) input = [value];
|
||||||
var value = ( depth === 2 ) ? [ value ] : value;
|
|
||||||
|
|
||||||
while ( i-- ) {
|
return input.map( function( x ) {
|
||||||
ret[i] = ( input[i] === '' || input[i] === undefined ) ? value : input[i];
|
return ( depth === 2 )
|
||||||
}
|
? Array.isArray( x )
|
||||||
|
? x.map( function(s) { return +s; } )
|
||||||
return ret;
|
: [ x ]
|
||||||
|
: ( x === '' || x === undefined ) ? value : +x;
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue