Fixed errors occurring because of undefined properties on nested paths.
This commit is contained in:
@@ -532,7 +532,7 @@ Handlebars.JavaScriptCompiler = function() {};
|
||||
|
||||
lookup: function(name) {
|
||||
var topStack = this.topStack();
|
||||
this.source.push(topStack + " = " + this.nameLookup(topStack, name, 'context') + ";");
|
||||
this.source.push(topStack + " = " + topStack + " ? " + this.nameLookup(topStack, name, 'context') + " : " + topStack + ";");
|
||||
},
|
||||
|
||||
pushStringParam: function(string) {
|
||||
|
||||
@@ -964,7 +964,6 @@ module("Regressions")
|
||||
test("GH-94: Cannot read property of undefined", function() {
|
||||
var data = {"books":[{"title":"The origin of species","author":{"name":"Charles Darwin"}},{"title":"Lazarillo de Tormes"}]};
|
||||
var string = "{{#books}}{{title}}{{author.name}}{{/books}}";
|
||||
p(tpl);
|
||||
shouldCompileTo(string, data, "The origin of speciesCharles DarwinLazarillo de Tormes",
|
||||
"Renders without an undefined property error");
|
||||
});
|
||||
Reference in New Issue
Block a user