diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index c58dcf13..6d6fd8fd 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -164,12 +164,10 @@ JavaScriptCompiler.prototype = { let { programs, decorators } = this.context; for (i = 0, l = programs.length; i < l; i++) { - if (programs[i]) { - ret[i] = programs[i]; - if (decorators[i]) { - ret[i + '_d'] = decorators[i]; - ret.useDecorators = true; - } + ret[i] = programs[i]; + if (decorators[i]) { + ret[i + '_d'] = decorators[i]; + ret.useDecorators = true; } } @@ -836,8 +834,8 @@ JavaScriptCompiler.prototype = { let existing = this.matchExistingProgram(child); if (existing == null) { - this.context.programs.push(''); // Placeholder to prevent name conflicts for nested children - let index = this.context.programs.length; + // Placeholder to prevent name conflicts for nested children + let index = this.context.programs.push('') - 1; child.index = index; child.name = 'program' + index; this.context.programs[index] = compiler.compile( diff --git a/spec/expected/non.empty.amd.known.helper.js b/spec/expected/non.empty.amd.known.helper.js index 75c81cdc..81e4b117 100644 --- a/spec/expected/non.empty.amd.known.helper.js +++ b/spec/expected/non.empty.amd.known.helper.js @@ -1,6 +1,6 @@ define(['handlebars.runtime'], function(Handlebars) { Handlebars = Handlebars["default"]; var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; -return templates['known.helpers'] = template({"1":function(container,depth0,helpers,partials,data) { +return templates['known.helpers'] = template({"0":function(container,depth0,helpers,partials,data) { var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) { if (Object.prototype.hasOwnProperty.call(parent, propertyName)) { return parent[propertyName]; @@ -8,8 +8,8 @@ return parent[propertyName]; return undefined }; return "