Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
getTeminatorAt recurses infinitely if template is its own terminator
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelw committed May 31, 2013
1 parent 8604073 commit 5846863
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/template_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,8 @@
if (index == -1)
return this.templateElement_;
var terminator = this.terminators[index];
if (terminator.nodeType !== Node.ELEMENT_NODE)
if (terminator.nodeType !== Node.ELEMENT_NODE ||
this.templateElement_ === terminator)
return terminator;

var subIterator = templateIteratorTable.get(terminator);
Expand Down
19 changes: 19 additions & 0 deletions tests/template_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,25 @@ suite('Template Element', function() {
assert.strictEqual('bar', div.childNodes[3].textContent);
});

test('Template - Self is terminator', function() {
var div = createTestHtml(
'<template repeat>{{ foo }}' +
'<template bind></template>' +
'</template>');

var m = [{ foo: 'bar' }];
recursivelySetTemplateModel(div, m);
Platform.performMicrotaskCheckpoint();

m.push({ foo: 'baz' });
recursivelySetTemplateModel(div, m);
Platform.performMicrotaskCheckpoint();

assert.strictEqual(5, div.childNodes.length);
assert.strictEqual('bar', div.childNodes[2].textContent);
assert.strictEqual('baz', div.childNodes[4].textContent);
});

test('ChangeFromBindToRepeat', function() {
var div = createTestHtml(
'<template bind="{{a}}">' +
Expand Down

0 comments on commit 5846863

Please sign in to comment.