diff --git a/packages/handlebars/evaluate.js b/packages/handlebars/evaluate.js index a9e7ddd19c..1accbc99c0 100644 --- a/packages/handlebars/evaluate.js +++ b/packages/handlebars/evaluate.js @@ -35,7 +35,7 @@ Handlebars._default_helpers = { if (data && data.length > 0) return _.map(data, function(x, i) { // infer a branch key from the data - var branch = (x._id || (typeof x === 'string' ? x : null) || + var branch = ((x && x._id) || (typeof x === 'string' ? x : null) || Spark.UNIQUE_LABEL); return Spark.labelBranch(branch, function() { return options.fn(x); diff --git a/packages/templating/deftemplate.js b/packages/templating/deftemplate.js index 9c24d72a72..4101628720 100644 --- a/packages/templating/deftemplate.js +++ b/packages/templating/deftemplate.js @@ -18,7 +18,7 @@ arg, function (item) { return Spark.labelBranch( - item._id || Spark.UNIQUE_LABEL, function () { + (item && item._id) || Spark.UNIQUE_LABEL, function () { var html = Spark.isolate(_.bind(options.fn, null, item)); return Spark.setDataContext(item, html); }); diff --git a/packages/templating/templating_tests.html b/packages/templating/templating_tests.html index bbe8dd8f41..2ad6fae73a 100644 --- a/packages/templating/templating_tests.html +++ b/packages/templating/templating_tests.html @@ -350,3 +350,8 @@ + + + diff --git a/packages/templating/templating_tests.js b/packages/templating/templating_tests.js index 49557b2820..40ad9dc4cc 100644 --- a/packages/templating/templating_tests.js +++ b/packages/templating/templating_tests.js @@ -1085,3 +1085,10 @@ Tinytest.add("templating - tricky branch labels", function (test) { div.kill(); Deps.flush(); }); + +Tinytest.add('templating - each falsy Issue #801', function (test) { + //Minor test for issue #801 + Template.test_template_issue801.values = function() { return [1,2,null,undefined]; }; + var frag = Meteor.render(Template.test_template_issue801); + test.equal(canonicalizeHtml(DomUtils.fragmentToHtml(frag)), "12null"); +});