| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Lazy implementation of the child nodes of an element that does not request | 8 * Lazy implementation of the child nodes of an element that does not request |
| 9 * the actual child nodes of an element until strictly necessary greatly | 9 * the actual child nodes of an element until strictly necessary greatly |
| 10 * improving performance for the typical cases where it is not required. | 10 * improving performance for the typical cases where it is not required. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 99 } |
| 100 | 100 |
| 101 Node removeAt(int index) { | 101 Node removeAt(int index) { |
| 102 var result = this[index]; | 102 var result = this[index]; |
| 103 if (result != null) { | 103 if (result != null) { |
| 104 _this.$dom_removeChild(result); | 104 _this.$dom_removeChild(result); |
| 105 } | 105 } |
| 106 return result; | 106 return result; |
| 107 } | 107 } |
| 108 | 108 |
| 109 void remove(Object object) { | 109 bool remove(Object object) { |
| 110 if (object is! Node) return; | 110 if (object is! Node) return false; |
| 111 Node node = object; | 111 Node node = object; |
| 112 if (!identical(_this, node.parentNode)) return; | 112 if (!identical(_this, node.parentNode)) return false; |
| 113 _this.$dom_removeChild(node); | 113 _this.$dom_removeChild(node); |
| 114 return true; |
| 114 } | 115 } |
| 115 | 116 |
| 116 void _filter(bool test(Node node), bool removeMatching) { | 117 void _filter(bool test(Node node), bool removeMatching) { |
| 117 // This implementation of removeWhere/retainWhere is more efficient | 118 // This implementation of removeWhere/retainWhere is more efficient |
| 118 // than the default in ListBase. Child nodes can be removed in constant | 119 // than the default in ListBase. Child nodes can be removed in constant |
| 119 // time. | 120 // time. |
| 120 Node child = _this.$dom_firstChild; | 121 Node child = _this.$dom_firstChild; |
| 121 while (child != null) { | 122 while (child != null) { |
| 122 Node nextChild = child.nextSibling; | 123 Node nextChild = child.nextSibling; |
| 123 if (test(child) == removeMatching) { | 124 if (test(child) == removeMatching) { |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 361 } |
| 361 | 362 |
| 362 /** | 363 /** |
| 363 * Print out a String representation of this Node. | 364 * Print out a String representation of this Node. |
| 364 */ | 365 */ |
| 365 String toString() => localName == null ? | 366 String toString() => localName == null ? |
| 366 (nodeValue == null ? super.toString() : nodeValue) : localName; | 367 (nodeValue == null ? super.toString() : nodeValue) : localName; |
| 367 | 368 |
| 368 $!MEMBERS | 369 $!MEMBERS |
| 369 } | 370 } |
| OLD | NEW |