summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/handlebars/compiler/javascript-compiler.js5
-rw-r--r--lib/handlebars/helpers/each.js10
2 files changed, 6 insertions, 9 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js
index d0f206c..bd48e9b 100644
--- a/lib/handlebars/compiler/javascript-compiler.js
+++ b/lib/handlebars/compiler/javascript-compiler.js
@@ -984,13 +984,14 @@ JavaScriptCompiler.prototype = {
setupHelper: function(paramSize, name, blockHelper) {
let params = [],
paramsInit = this.setupHelperArgs(name, paramSize, params, blockHelper);
- let foundHelper = this.nameLookup('helpers', name, 'helper');
+ let foundHelper = this.nameLookup('helpers', name, 'helper'),
+ callContext = this.aliasable(`${this.contextName(0)} != null ? ${this.contextName(0)} : {}`);
return {
params: params,
paramsInit: paramsInit,
name: foundHelper,
- callParams: [this.contextName(0)].concat(params)
+ callParams: [callContext].concat(params)
};
},
diff --git a/lib/handlebars/helpers/each.js b/lib/handlebars/helpers/each.js
index 9b1629b..fb11903 100644
--- a/lib/handlebars/helpers/each.js
+++ b/lib/handlebars/helpers/each.js
@@ -25,12 +25,6 @@ export default function(instance) {
}
function execIteration(field, index, last) {
- // Don't iterate over undefined values since we can't execute blocks against them
- // in non-strict (js) mode.
- if (context[field] == null) {
- return;
- }
-
if (data) {
data.key = field;
data.index = index;
@@ -51,7 +45,9 @@ export default function(instance) {
if (context && typeof context === 'object') {
if (isArray(context)) {
for (let j = context.length; i < j; i++) {
- execIteration(i, i, i === context.length - 1);
+ if (i in context) {
+ execIteration(i, i, i === context.length - 1);
+ }
}
} else {
let priorKey;