Index: sdk/lib/html/dart2js/html_dart2js.dart |
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart |
index 7b1715456fb692d4587ca85eabda81f4f3046005..66ae044cf26a20dd846535efce55619a9ad5d80b 100644 |
--- a/sdk/lib/html/dart2js/html_dart2js.dart |
+++ b/sdk/lib/html/dart2js/html_dart2js.dart |
@@ -43724,9 +43724,18 @@ class _ValidatingTreeSanitizer implements NodeTreeSanitizer { |
sanitizeNode(node, parent); |
var child = node.lastChild; |
- while (child != null) { |
- // Child may be removed during the walk. |
- var nextChild = child.previousNode; |
+ while (!identical(child, null)) { |
+ var nextChild; |
+ try { |
+ // Child may be removed during the walk, and we may not |
+ // even be able to get its previousNode. |
+ nextChild = child.previousNode; |
+ } catch (e) { |
+ // child appears bad, remove it and restart the traversal without it. |
+ _removeNode(child, node); |
+ walk(node, parent); |
+ return; |
+ } |
walk(child, node); |
child = nextChild; |
} |