Skip to content

Commit

Permalink
FLUID-4128: Fix and test cases for renderer expansion bug in conditio…
Browse files Browse the repository at this point in the history
…nal expander, where context-relative resolved values are converted to string type
  • Loading branch information
amb26 committed Mar 2, 2011
1 parent f5f8564 commit c6298c9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/webapp/framework/core/js/Fluid.js
Expand Up @@ -45,8 +45,8 @@ var fluid = fluid || fluid_1_4;
fluid.fail = function (message) {
fluid.setLogging(true);
fluid.log(message.message ? message.message : message);
throw new Error(message);
//message.fail(); // Intentionally cause a browser error by invoking a nonexistent function.
//throw new Error(message);
message.fail(); // Intentionally cause a browser error by invoking a nonexistent function.
};

// Logging
Expand Down
2 changes: 1 addition & 1 deletion src/webapp/framework/core/js/FluidIoC.js
Expand Up @@ -596,7 +596,6 @@ var fluid_1_4 = fluid_1_4 || {};
while (typeof(string) === "string") {
var i1 = string.indexOf("${");
var i2 = string.indexOf("}", i1 + 2);
var all = (i1 === 0 && i2 === string.length - 1);
if (i1 !== -1 && i2 !== -1) {
var parsed;
if (string.charAt(i1 + 2) === "{") {
Expand All @@ -607,6 +606,7 @@ var fluid_1_4 = fluid_1_4 || {};
parsed = {path: string.substring(i1 + 2, i2)};
}
var subs = options.fetcher(parsed);
var all = (i1 === 0 && i2 === string.length - 1);
// TODO: test case for all undefined substitution
if (subs === undefined || subs === null) {
return subs;
Expand Down
2 changes: 1 addition & 1 deletion src/webapp/framework/renderer/js/RendererUtilities.js
Expand Up @@ -278,7 +278,7 @@ fluid_1_4 = fluid_1_4 || {};
} else if (options.condition.expander) {
condition = config.expander(options.condition);
} else {
condition = options.condition;
condition = config.expandLight(options.condition);
}
var tree = (condition ? options.trueTree : options.falseTree);
if (!tree) {
Expand Down
Expand Up @@ -790,6 +790,35 @@ fluid.registerNamespace("fluid.tests");
return;
});

protoTests.test("FLUID-4128 test: Literal booleans within repetition/condition expander", function() {
var model = {conditions: [true, false, true, true, false]};
var expander = fluid.renderer.makeProtoExpander({model: model});
var protoTree = {
expander: {
type: "fluid.renderer.repeat",
repeatID: "repeat-row:",
pathAs: "row",
valueAs: "rowValue",
controlledBy: "conditions",
tree: {
expander: {
type: "fluid.renderer.condition",
condition: "{rowValue}",
trueTree: {
leafValue: "{rowValue}"
}
}
}
}
}
var expanded = expander(protoTree);
jqUnit.assertEquals("Only three rows produced", 3, expanded.children.length);
var protoTree2 = fluid.copy(protoTree);
protoTree.expander.tree.expander.condition = "${{rowValue}}";
var expanded = expander(protoTree);
jqUnit.assertEquals("Only three rows produced - alternative reference style", 3, expanded.children.length);
});

protoTests.test("FLUID-3658 test: selection to inputs expander", function () {
var model = { };
var expopts = {ELstyle: "${}", model: model};
Expand All @@ -811,7 +840,7 @@ fluid.registerNamespace("fluid.tests");
}
},
"permissions-record-type": "${fields.permissions.0.recordType}"
}
}
]
}
};
Expand Down

0 comments on commit c6298c9

Please sign in to comment.