Goktug Gokdogan has uploaded a new change for review.
https://gwt-review.googlesource.com/3511
Change subject: Adds Node#removeAllChildren.
......................................................................
Adds Node#removeAllChildren.
Change-Id: Ic607bf6523a41c0ee4020a12e8505b1d8b39d916
---
M user/src/com/google/gwt/dom/client/Node.java
M user/test/com/google/gwt/dom/client/NodeTest.java
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/user/src/com/google/gwt/dom/client/Node.java
b/user/src/com/google/gwt/dom/client/Node.java
index 7433829..0f34f1e 100644
--- a/user/src/com/google/gwt/dom/client/Node.java
+++ b/user/src/com/google/gwt/dom/client/Node.java
@@ -292,6 +292,15 @@
}-*/;
/**
+ * Remove all children of the node.
+ */
+ public final native Node removeAllChildren() /*-{
+ while (this.lastChild) {
+ this.removeChild(this.lastChild);
+ }
+ }-*/;
+
+ /**
* Removes this node from its parent node if it is attached to one.
*/
public final void removeFromParent() {
diff --git a/user/test/com/google/gwt/dom/client/NodeTest.java
b/user/test/com/google/gwt/dom/client/NodeTest.java
index fe9935f..eddaf4b 100644
--- a/user/test/com/google/gwt/dom/client/NodeTest.java
+++ b/user/test/com/google/gwt/dom/client/NodeTest.java
@@ -40,7 +40,7 @@
// <div>foo<button/>bar</div>
DivElement div = doc.createDivElement();
Text txt0 = doc.createTextNode("foo");
- ButtonElement btn0 = doc.createButtonElement();
+ ButtonElement btn0 = doc.createPushButtonElement();
Text txt1 = doc.createTextNode("bar");
body.appendChild(div);
@@ -49,7 +49,7 @@
div.appendChild(txt1);
// appendChild, insertBefore
- ButtonElement btn1 = doc.createButtonElement();
+ ButtonElement btn1 = doc.createPushButtonElement();
// <div>foo<btn0/>bar<btn1/></div>
div.appendChild(btn1);
@@ -88,6 +88,23 @@
assertEquals(txt0, div.getFirstChild());
}
+ public void testRemoveAllChildren() throws Exception {
+ Document doc = Document.get();
+ BodyElement body = doc.getBody();
+
+ DivElement div = doc.createDivElement();
+ div.appendChild(doc.createTextNode("foo"));
+ div.appendChild(doc.createAnchorElement());
+ div.appendChild(doc.createTextNode("bar"));
+ body.appendChild(div);
+
+ assertEquals("foo<a></a>bar", div.getInnerHTML());
+
+ div.removeAllChildren();
+ assertEquals("", div.getInnerHTML());
+ assertEquals(0, div.getChildCount());
+ }
+
/**
* setAttribute, getAttribute, hasAttributes, hasAttribute.
*/
--
To view, visit https://gwt-review.googlesource.com/3511
To unsubscribe, visit https://gwt-review.googlesource.com/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic607bf6523a41c0ee4020a12e8505b1d8b39d916
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Goktug Gokdogan <gok...@google.com>
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
---
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.