Skip to content

Commit

Permalink
[sort-group] even more simple flow
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Nov 29, 2011
1 parent 3b74458 commit 9e6821e
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions lib/xjst/engines/sort-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,27 +214,27 @@ module.exports = function engine(templates, options, values) {
return handlers.slice(0, index);
}

if (tree['switch']) {
if (tree['default']['switch'] || tree['default'].stmt !== errStmt) {
handlers.push(tree['default']);
} else {
handlers = sliceHandlers(handlers, tree);

if (handlers.length > 0) {
// Update node's default and lift state
liftState(tree, tree['default'] = lastHandler());
}
if (!tree['switch']) return tree;

handlers = sliceHandlers(handlers, tree);

if (tree['default']['switch'] || tree['default'].stmt !== errStmt) {
handlers.push(tree['default']);
} else {
if (handlers.length > 0) {
// Update node's default and lift state
liftState(tree, tree['default'] = lastHandler());
}
}

tree.cases.forEach(function(branch) {
propagateErrors(branch[1], [].concat(handlers));
});
tree.cases.forEach(function(branch) {
propagateErrors(branch[1], [].concat(handlers));
});

// Prevent looping
handlers = sliceHandlers(handlers, tree['default']);
// Prevent looping
handlers = sliceHandlers(handlers, tree['default']);

propagateErrors(tree['default'], [].concat(handlers));
}
propagateErrors(tree['default'], [].concat(handlers));

return tree;
}
Expand Down

0 comments on commit 9e6821e

Please sign in to comment.