summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/handlebars/compiler/javascript-compiler.js2
-rw-r--r--spec/regressions.js19
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js
index 356424b..9bd70be 100644
--- a/lib/handlebars/compiler/javascript-compiler.js
+++ b/lib/handlebars/compiler/javascript-compiler.js
@@ -696,6 +696,8 @@ JavaScriptCompiler.prototype = {
} else {
child.index = index;
child.name = 'program' + index;
+
+ this.useDepths = this.useDepths || child.depths.list.length;
}
}
},
diff --git a/spec/regressions.js b/spec/regressions.js
index 11207fc..84b9d0c 100644
--- a/spec/regressions.js
+++ b/spec/regressions.js
@@ -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');
+ });
});