summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/helpers/each.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2015-09-23 21:17:57 -0500
committerkpdecker <kpdecker@gmail.com>2015-09-23 21:17:57 -0500
commitfffb5a985f8ff7cd75f2c16b37b69f7ddd3ba9a0 (patch)
treef43a388545445d40e0187db7993c9bf30c4507dd /lib/handlebars/helpers/each.js
parent08781798f564a68abee11c74e2b98272657b2a56 (diff)
downloadhandlebars.js-fffb5a985f8ff7cd75f2c16b37b69f7ddd3ba9a0.zip
handlebars.js-fffb5a985f8ff7cd75f2c16b37b69f7ddd3ba9a0.tar.gz
handlebars.js-fffb5a985f8ff7cd75f2c16b37b69f7ddd3ba9a0.tar.bz2
Fix iteration over undefined values
Allow for iteration on undefined values, but special case undefined and null to prevent rendering errors when not running in strict mode. Fixes #1093
Diffstat (limited to 'lib/handlebars/helpers/each.js')
-rw-r--r--lib/handlebars/helpers/each.js10
1 files changed, 3 insertions, 7 deletions
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;