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 html; | 5 part of html; |
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 int get length => _this.$dom_childNodes.length; | 196 int get length => _this.$dom_childNodes.length; |
197 | 197 |
198 void set length(int value) { | 198 void set length(int value) { |
199 throw new UnsupportedError( | 199 throw new UnsupportedError( |
200 "Cannot set length on immutable List."); | 200 "Cannot set length on immutable List."); |
201 } | 201 } |
202 | 202 |
203 Node operator[](int index) => _this.$dom_childNodes[index]; | 203 Node operator[](int index) => _this.$dom_childNodes[index]; |
204 } | 204 } |
205 | 205 |
206 /// @domName $DOMNAME | 206 @DomName("$DOMNAME") |
207 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 207 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
208 List<Node> get nodes { | 208 List<Node> get nodes { |
209 return new _ChildNodeListLazy(this); | 209 return new _ChildNodeListLazy(this); |
210 } | 210 } |
211 | 211 |
212 void set nodes(Collection<Node> value) { | 212 void set nodes(Collection<Node> value) { |
213 // Copy list first since we don't want liveness during iteration. | 213 // Copy list first since we don't want liveness during iteration. |
214 // TODO(jacobr): there is a better way to do this. | 214 // TODO(jacobr): there is a better way to do this. |
215 List copy = new List.from(value); | 215 List copy = new List.from(value); |
216 text = ''; | 216 text = ''; |
217 for (Node node in copy) { | 217 for (Node node in copy) { |
218 $dom_appendChild(node); | 218 $dom_appendChild(node); |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 /** | 222 /** |
223 * Removes this node from the DOM. | 223 * Removes this node from the DOM. |
224 * @domName Node.removeChild | |
225 */ | 224 */ |
| 225 @DomName("Node.removeChild") |
226 void remove() { | 226 void remove() { |
227 // TODO(jacobr): should we throw an exception if parent is already null? | 227 // TODO(jacobr): should we throw an exception if parent is already null? |
228 // TODO(vsm): Use the native remove when available. | 228 // TODO(vsm): Use the native remove when available. |
229 if (this.parentNode != null) { | 229 if (this.parentNode != null) { |
230 final Node parent = this.parentNode; | 230 final Node parent = this.parentNode; |
231 parentNode.$dom_removeChild(this); | 231 parentNode.$dom_removeChild(this); |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 /** | 235 /** |
236 * Replaces this node with another node. | 236 * Replaces this node with another node. |
237 * @domName Node.replaceChild | |
238 */ | 237 */ |
| 238 @DomName("Node.replaceChild") |
239 Node replaceWith(Node otherNode) { | 239 Node replaceWith(Node otherNode) { |
240 try { | 240 try { |
241 final Node parent = this.parentNode; | 241 final Node parent = this.parentNode; |
242 parent.$dom_replaceChild(otherNode, this); | 242 parent.$dom_replaceChild(otherNode, this); |
243 } catch (e) { | 243 } catch (e) { |
244 | 244 |
245 }; | 245 }; |
246 return this; | 246 return this; |
247 } | 247 } |
248 | 248 |
249 $!MEMBERS | 249 $!MEMBERS |
250 } | 250 } |
OLD | NEW |