Track depths on deduped children

Fixes a very specific error case where deduped children won’t receive the depths object due to it being omitted by the caller when optimizing.

Fixes #926
This commit is contained in:
kpdecker
2014-12-16 17:58:26 -06:00
parent 69b1bdd32e
commit 59e80c5103
2 changed files with 20 additions and 1 deletions
+18 -1
View File
@@ -1,4 +1,4 @@
/*global CompilerContext, Handlebars, shouldCompileTo, shouldThrow */
/*global CompilerContext, shouldCompileTo, shouldThrow */
describe('Regressions', function() {
it("GH-94: Cannot read property of undefined", function() {
var data = {"books":[{"title":"The origin of species","author":{"name":"Charles Darwin"}},{"title":"Lazarillo de Tormes"}]};
@@ -145,4 +145,21 @@ describe('Regressions', function() {
shouldCompileTo('{{str bar.baz}}', [{}, helpers], 'undefined');
});
it('GH-926: Depths and de-dupe', function() {
var context = {
name: 'foo',
data: [
1
],
notData: [
1
]
};
var template = CompilerContext.compile('{{#if dater}}{{#each data}}{{../name}}{{/each}}{{else}}{{#each notData}}{{../name}}{{/each}}{{/if}}');
var result = template(context);
equals(result, 'foo');
});
});