Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2509)

Unified Diff: pkg/mdv/lib/src/template_iterator.dart

Issue 19672018: [mdv] getTeminatorAt recurses infinitely if template is its own terminator (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/mdv/test/template_element_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/mdv/lib/src/template_iterator.dart
diff --git a/pkg/mdv/lib/src/template_iterator.dart b/pkg/mdv/lib/src/template_iterator.dart
index 67bc1235c647c3769f0af4c5da7891f67fbd6cb5..82c4a7f24cb05a2877b4a32e036229eaeb016299 100644
--- a/pkg/mdv/lib/src/template_iterator.dart
+++ b/pkg/mdv/lib/src/template_iterator.dart
@@ -235,7 +235,8 @@ class _TemplateIterator {
Node getTerminatorAt(int index) {
justinfagnani 2013/07/23 19:59:40 for my own education, what's a terminator?
Jennifer Messerly 2013/07/23 20:13:00 you know almost as much as I do :) from the code,
if (index == -1) return _templateElement;
var terminator = terminators[index];
- if (terminator is Element && (terminator as Element).isTemplate) {
+ if (terminator is Element && (terminator as Element).isTemplate &&
+ !identical(terminator, _templateElement)) {
var subIterator = _mdv(terminator)._templateIterator;
if (subIterator != null) {
return subIterator.getTerminatorAt(subIterator.terminators.length - 1);
@@ -267,8 +268,8 @@ class _TemplateIterator {
var parent = _templateElement.parentNode;
while (terminator != previousTerminator) {
- var node = terminator;
- terminator = node.previousNode;
+ var node = previousTerminator.nextNode;
+ if (node == terminator) terminator = previousTerminator;
node.remove();
instanceNodes.add(node);
}
@@ -314,6 +315,7 @@ class _TemplateIterator {
for (var splice in splices) {
for (int i = 0; i < splice.removedCount; i++) {
var instanceNodes = extractInstanceAt(splice.index + removeDelta);
+ if (instanceNodes.length == 0) continue;
var model = _mdv(instanceNodes.first)._templateInstance.model;
instanceCache[model] = instanceNodes;
}
« no previous file with comments | « no previous file | pkg/mdv/test/template_element_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698