Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: tools/dom/templates/html/impl/impl_Node.darttemplate

Issue 12596004: Replaced Element.append with Node.appendChild (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/dom/templates/html/impl/impl_Element.darttemplate ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 Node min([int compare(Node a, Node b)]) { 54 Node min([int compare(Node a, Node b)]) {
55 return IterableMixinWorkaround.min(this, compare); 55 return IterableMixinWorkaround.min(this, compare);
56 } 56 }
57 57
58 Node max([int compare(Node a, Node b)]) { 58 Node max([int compare(Node a, Node b)]) {
59 return IterableMixinWorkaround.max(this, compare); 59 return IterableMixinWorkaround.max(this, compare);
60 } 60 }
61 61
62 void add(Node value) { 62 void add(Node value) {
63 _this.$dom_appendChild(value); 63 _this.append(value);
64 } 64 }
65 65
66 void addLast(Node value) { 66 void addLast(Node value) {
67 _this.$dom_appendChild(value); 67 _this.append(value);
68 } 68 }
69 69
70 70
71 void addAll(Iterable<Node> iterable) { 71 void addAll(Iterable<Node> iterable) {
72 if (iterable is _ChildNodeListLazy) { 72 if (iterable is _ChildNodeListLazy) {
73 if (!identical(iterable._this, _this)) { 73 if (!identical(iterable._this, _this)) {
74 // Optimized route for copying between nodes. 74 // Optimized route for copying between nodes.
75 for (var i = 0, len = iterable.length; i < len; ++i) { 75 for (var i = 0, len = iterable.length; i < len; ++i) {
76 // Should use $dom_firstChild, Bug 8886. 76 // Should use $dom_firstChild, Bug 8886.
77 _this.$dom_appendChild(iterable[0]); 77 _this.append(iterable[0]);
78 } 78 }
79 } 79 }
80 return; 80 return;
81 } 81 }
82 for (Node node in iterable) { 82 for (Node node in iterable) {
83 _this.$dom_appendChild(node); 83 _this.append(node);
84 } 84 }
85 } 85 }
86 86
87 Node removeLast() { 87 Node removeLast() {
88 final result = last; 88 final result = last;
89 if (result != null) { 89 if (result != null) {
90 _this.$dom_removeChild(result); 90 _this.$dom_removeChild(result);
91 } 91 }
92 return result; 92 return result;
93 } 93 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 List<Node> get nodes { 256 List<Node> get nodes {
257 return new _ChildNodeListLazy(this); 257 return new _ChildNodeListLazy(this);
258 } 258 }
259 259
260 void set nodes(Collection<Node> value) { 260 void set nodes(Collection<Node> value) {
261 // Copy list first since we don't want liveness during iteration. 261 // Copy list first since we don't want liveness during iteration.
262 // TODO(jacobr): there is a better way to do this. 262 // TODO(jacobr): there is a better way to do this.
263 List copy = new List.from(value); 263 List copy = new List.from(value);
264 text = ''; 264 text = '';
265 for (Node node in copy) { 265 for (Node node in copy) {
266 $dom_appendChild(node); 266 append(node);
267 } 267 }
268 } 268 }
269 269
270 /** 270 /**
271 * Removes this node from the DOM. 271 * Removes this node from the DOM.
272 */ 272 */
273 @DomName('Node.removeChild') 273 @DomName('Node.removeChild')
274 void remove() { 274 void remove() {
275 // TODO(jacobr): should we throw an exception if parent is already null? 275 // TODO(jacobr): should we throw an exception if parent is already null?
276 // TODO(vsm): Use the native remove when available. 276 // TODO(vsm): Use the native remove when available.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 314 }
315 } else { 315 } else {
316 for (var node in newNodes) { 316 for (var node in newNodes) {
317 this.insertBefore(node, refChild); 317 this.insertBefore(node, refChild);
318 } 318 }
319 } 319 }
320 } 320 }
321 321
322 $!MEMBERS 322 $!MEMBERS
323 } 323 }
OLDNEW
« no previous file with comments | « tools/dom/templates/html/impl/impl_Element.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698