From 0b0434ba9b8e86d8006d64145a4208c004192b08 Mon Sep 17 00:00:00 2001 From: guybedford Date: Tue, 16 Feb 2016 14:59:38 +0200 Subject: [PATCH] allow conditionals to chain --- lib/trace.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/trace.js b/lib/trace.js index 0b4e926..b0bb587 100644 --- a/lib/trace.js +++ b/lib/trace.js @@ -639,6 +639,17 @@ Trace.prototype.inlineConditions = function(tree, loader, conditionalEnv) { conditionalResolutions[c] = branches[0]; }); + // resolve any chained conditionals + Object.keys(conditionalResolutions).forEach(function(c) { + var resolution = conditionalResolutions[c]; + + // yes this hangs on circular... + while (conditionalResolutions[resolution]) { + resolution = conditionalResolutions[resolution]; + conditionalResolutions[c] = resolution; + } + }); + // finally we do a deep clone of the tree, applying the conditional resolutions as we go // if we have a dependency on a condition not in the tree, we throw as it would be an unresolved external var inlinedTree = {};