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 /** | 5 /** |
6 * Lazy implementation of the child nodes of an element that does not request | 6 * Lazy implementation of the child nodes of an element that does not request |
7 * the actual child nodes of an element until strictly necessary greatly | 7 * the actual child nodes of an element until strictly necessary greatly |
8 * improving performance for the typical cases where it is not required. | 8 * improving performance for the typical cases where it is not required. |
9 */ | 9 */ |
10 class _ChildNodeListLazy implements List { | 10 class _ChildNodeListLazy implements List { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 bool some(bool f(Node element)) => _Collections.some(this, f); | 70 bool some(bool f(Node element)) => _Collections.some(this, f); |
71 | 71 |
72 bool isEmpty() => this.length == 0; | 72 bool isEmpty() => this.length == 0; |
73 | 73 |
74 // From List<Node>: | 74 // From List<Node>: |
75 | 75 |
76 // TODO(jacobr): this could be implemented for child node lists. | 76 // TODO(jacobr): this could be implemented for child node lists. |
77 // The exception we throw here is misleading. | 77 // The exception we throw here is misleading. |
78 void sort([Comparator<Node> compare = Comparable.compare]) { | 78 void sort([Comparator<Node> compare = Comparable.compare]) { |
79 throw new UnsupportedOperationException("Cannot sort immutable List."); | 79 throw new UnsupportedError("Cannot sort immutable List."); |
80 } | 80 } |
81 | 81 |
82 int indexOf(Node element, [int start = 0]) => | 82 int indexOf(Node element, [int start = 0]) => |
83 _Lists.indexOf(this, element, start, this.length); | 83 _Lists.indexOf(this, element, start, this.length); |
84 | 84 |
85 int lastIndexOf(Node element, [int start = 0]) => | 85 int lastIndexOf(Node element, [int start = 0]) => |
86 _Lists.lastIndexOf(this, element, start); | 86 _Lists.lastIndexOf(this, element, start); |
87 | 87 |
88 // FIXME: implement these. | 88 // FIXME: implement these. |
89 void setRange(int start, int rangeLength, List<Node> from, [int startFrom]) { | 89 void setRange(int start, int rangeLength, List<Node> from, [int startFrom]) { |
90 throw new UnsupportedOperationException( | 90 throw new UnsupportedError( |
91 "Cannot setRange on immutable List."); | 91 "Cannot setRange on immutable List."); |
92 } | 92 } |
93 void removeRange(int start, int rangeLength) { | 93 void removeRange(int start, int rangeLength) { |
94 throw new UnsupportedOperationException( | 94 throw new UnsupportedError( |
95 "Cannot removeRange on immutable List."); | 95 "Cannot removeRange on immutable List."); |
96 } | 96 } |
97 void insertRange(int start, int rangeLength, [Node initialValue]) { | 97 void insertRange(int start, int rangeLength, [Node initialValue]) { |
98 throw new UnsupportedOperationException( | 98 throw new UnsupportedError( |
99 "Cannot insertRange on immutable List."); | 99 "Cannot insertRange on immutable List."); |
100 } | 100 } |
101 List<Node> getRange(int start, int rangeLength) => | 101 List<Node> getRange(int start, int rangeLength) => |
102 new _NodeListWrapper(_Lists.getRange(this, start, rangeLength, <Node>[])); | 102 new _NodeListWrapper(_Lists.getRange(this, start, rangeLength, <Node>[])); |
103 | 103 |
104 // -- end List<Node> mixins. | 104 // -- end List<Node> mixins. |
105 | 105 |
106 // TODO(jacobr): benchmark whether this is more efficient or whether caching | 106 // TODO(jacobr): benchmark whether this is more efficient or whether caching |
107 // a local copy of $dom_childNodes is more efficient. | 107 // a local copy of $dom_childNodes is more efficient. |
108 int get length => _this.$dom_childNodes.length; | 108 int get length => _this.$dom_childNodes.length; |
(...skipping 30 matching lines...) Expand all Loading... |
139 final _NodeImpl parent = this.parent; | 139 final _NodeImpl parent = this.parent; |
140 parent.$dom_replaceChild(otherNode, this); | 140 parent.$dom_replaceChild(otherNode, this); |
141 } catch (e) { | 141 } catch (e) { |
142 | 142 |
143 }; | 143 }; |
144 return this; | 144 return this; |
145 } | 145 } |
146 | 146 |
147 $!MEMBERS | 147 $!MEMBERS |
148 } | 148 } |
OLD | NEW |