Mishandling null, undefined, and array results from ixsl functions
Incorrect results are being returned from expressions such as empty(ixsl:eval('null')), ixsl:eval('[1,2,3]'), and ixsl:get(ixsl:window() , 'nullObj') where var nullObj = null.
JS arrays should be converted to XDM sequences - internally this is an iterator Iter.ForArray(a). There are cases where we just put all converted results in Iter.Singleton(), neglecting the case for arrays/sequences (e.g. ixsl:eval()).
There are some cases where we do check for null and/or undefined before converting (using convertFromJS) and handle these separately (to return Iter.Empty), but we should be consistent that we always check for an array after converting (and in that case the check for null/undefined beforehand is unnecessary). So always use something like:
var y = Expr.convertFromJS(x); return Array.isArray(y) ? Iter.ForArray(y) : Iter.Singleton(y);
#1 Updated by Debbie Lockett 9 months ago
- Status changed from New to Resolved
- Fix Committed on JS Branch 1.0, Trunk added
Checked how we handle results for all uses of Expr.convertFromJS(). Code fixes only required for implementations of ixsl:get() and ixsl:eval(); other uses are being handled correctly.
Code fixes committed on 1.0 and 2.0 branches.
JS unit tests ixsl/get03 and ixsl/eval03 tests added.
Please register to edit this issue