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

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

Issue 12383073: Add List.insert. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use insertBefore and add is-check. 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
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 _this.$dom_appendChild(iterable[0]); 77 _this.$dom_appendChild(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.$dom_appendChild(node);
84 } 84 }
85 } 85 }
86 86
87 void insert(int index, Node node) {
88 if (index < 0 || index > length) {
89 throw new RangeError.range(index, 0, length);
90 }
91 if (index == length) {
92 _this.$dom_appendChild(node);
93 } else {
94 this_.insertBefore(node, this[index]);
95 }
96 }
97
87 Node removeLast() { 98 Node removeLast() {
88 final result = last; 99 final result = last;
89 if (result != null) { 100 if (result != null) {
90 _this.$dom_removeChild(result); 101 _this.$dom_removeChild(result);
91 } 102 }
92 return result; 103 return result;
93 } 104 }
94 105
95 Node removeAt(int index) { 106 Node removeAt(int index) {
96 var result = this[index]; 107 var result = this[index];
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 325 }
315 } else { 326 } else {
316 for (var node in newNodes) { 327 for (var node in newNodes) {
317 this.insertBefore(node, refChild); 328 this.insertBefore(node, refChild);
318 } 329 }
319 } 330 }
320 } 331 }
321 332
322 $!MEMBERS 333 $!MEMBERS
323 } 334 }
OLDNEW
« no previous file with comments | « tools/dom/templates/html/impl/impl_Element.darttemplate ('k') | tools/dom/templates/immutable_list_mixin.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698