diff --git a/packages/templating/deftemplate.js b/packages/templating/deftemplate.js index 32bb7b28cc..3245abe6f8 100644 --- a/packages/templating/deftemplate.js +++ b/packages/templating/deftemplate.js @@ -79,7 +79,8 @@ Sky._def_template = function (name, raw_func) { if (replacement) { elt.replaceChild(replacement, child); delete Sky._pending_partials[child.id]; - child = elt.childNodes[i]; + i--; + continue; } traverse(child); } diff --git a/tests/liverange/client/template_test.js b/tests/liverange/client/template_test.js index 512886ba90..e3aad86e7c 100644 --- a/tests/liverange/client/template_test.js +++ b/tests/liverange/client/template_test.js @@ -1,6 +1,10 @@ test("template assembly", function () { // Test for a bug that made it to production -- after a replacement, // also check the newly replaced node for replacements - var x = Template.test_assembly_3(); + var x = Template.test_assembly_0(); assert.lengthIs(x.childNodes, 1); }); + + +// Test that if a template throws an error, then pending_partials is +// cleaned up properly (that template rendering doesn't break..) \ No newline at end of file