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

Unified Diff: tools/dom/templates/html/impl/impl_Node.darttemplate

Issue 12374060: Adding Node.insertAllBefore (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/node_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/templates/html/impl/impl_Node.darttemplate
diff --git a/tools/dom/templates/html/impl/impl_Node.darttemplate b/tools/dom/templates/html/impl/impl_Node.darttemplate
index 307cd0cea96e329577874641d1b269bf174c973d..5782724089feb30d8cdbdcd2279f4bf499bf5660 100644
--- a/tools/dom/templates/html/impl/impl_Node.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Node.darttemplate
@@ -70,9 +70,10 @@ $endif
void addAll(Iterable<Node> iterable) {
if (iterable is _ChildNodeListLazy) {
- if (iterable._this != _this) {
+ if (!identical(iterable._this, _this)) {
// Optimized route for copying between nodes.
for (var i = 0, len = iterable.length; i < len; ++i) {
+ // Should use $dom_firstChild, Bug 8886.
_this.$dom_appendChild(iterable[0]);
}
}
@@ -291,5 +292,30 @@ $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
return this;
}
+ /**
+ * Inserts all of the nodes into this node directly before refChild.
+ *
+ * See also:
+ *
+ * * [insertBefore]
+ */
+ Node insertAllBefore(Iterable<Node> newNodes, Node refChild) {
+ if (newNodes is _ChildNodeListLazy) {
+ if (identical(newNodes._this, this)) {
+ throw new ArgumentError(newNodes);
+ }
+
+ // Optimized route for copying between nodes.
+ for (var i = 0, len = newNodes.length; i < len; ++i) {
+ // Should use $dom_firstChild, Bug 8886.
+ this.insertBefore(newNodes[0], refChild);
+ }
+ } else {
+ for (var node in newNodes) {
+ this.insertBefore(node, refChild);
+ }
+ }
+ }
+
$!MEMBERS
}
« no previous file with comments | « tests/html/node_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698