FLUID-5608: fluid.transforms.valueMapper does not support "false" literal target values

Metadata

Source
FLUID-5608
Type
Bug
Priority
Major
Status
Closed
Resolution
Fixed
Assignee
Kasper Galschiot Markus
Reporter
Simon Bates
Created
2015-03-26T10:37:09.354-0400
Updated
2024-07-22T10:35:04.235-0400
Versions
N/A
Fixed Versions
N/A
Component
  1. Model Transformation System

Description

The fluid.transforms.valueMapper function contains the following logic:

var indexed = deref(value);
if (!indexed) {
    // if no branch matches, try again using this value - WARNING, this seriously
    // threatens invertibility
    indexed = deref(transformSpec.defaultInputValue);
}
if (!indexed) {
    return;
}

https://github.com/fluid-project/infusion/blob/master/src/framework/core/js/ModelTransformationTransforms.js#L258-L266

If deref() finds a "false" literal value, it will be treated as no value found. This results in code like the following being necessary:

singleTransform: {
    type: "fluid.transforms.valueMapper",
    inputPath: "",
    defaultInputValue: "otherwise",
    options: {
        "checked": true,
        "indeterminate": true,
        "otherwise": { outputValue: false }
    }
}

The use of "{ outputValue: false }" is necessary to give deref() a non-falsey value.