Chromium Code Reviews| Index: tools/dom/src/Validators.dart |
| diff --git a/tools/dom/src/Validators.dart b/tools/dom/src/Validators.dart |
| index 4dbe32c5942269275d38bf590e5d6a5cf60e1c0f..249ddeeb1b06901ba85fe33d83a3a4a84eaf0760 100644 |
| --- a/tools/dom/src/Validators.dart |
| +++ b/tools/dom/src/Validators.dart |
| @@ -167,9 +167,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)) { |
|
sra1
2016/03/25 17:20:12
!= null is fine - null as an explicit argument is
Alan Knight
2016/03/25 18:10:46
OK, just being extremely paranoid. Made it 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. |
|
sra1
2016/03/25 17:20:12
Say why a restart is necessary instead of just rem
Alan Knight
2016/03/25 18:10:46
Added comment. Rewrote it to not be recursive.
|
| + _removeNode(child, node); |
| + walk(node, parent); |
| + return; |
| + } |
| walk(child, node); |
| child = nextChild; |
| } |