Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
allow conditionals to chain
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Feb 16, 2016
1 parent 2feeb60 commit 0b0434b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down

0 comments on commit 0b0434b

Please sign in to comment.