Merge branch 'devel-#801-fixed' of git://github.com/raix/meteor into raix-815

This commit is contained in:
Chris Mather
2013-03-14 17:20:53 -07:00
4 changed files with 14 additions and 2 deletions

View File

@@ -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);

View File

@@ -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);
});

View File

@@ -350,3 +350,8 @@
<template name="test_template_trickylabels_a2">
<div>foo</div>
</template>
<!-- Test for issue #801 - Each handling of falsy values eg. [1, 2, null, undefined] -->
<template name="test_template_issue801">
{{#each values}}{{this}}{{/each}}
</template>

View File

@@ -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");
});