Rollback of r2874. The fix for Issue 960 breaks StyleInjector, so we need
to figure out a better way to get whitespace normalization.
Review by: bobv
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2931 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/dom/client/DOMImpl.java b/user/src/com/google/gwt/dom/client/DOMImpl.java
index 928f3a3..3369ea2 100644
--- a/user/src/com/google/gwt/dom/client/DOMImpl.java
+++ b/user/src/com/google/gwt/dom/client/DOMImpl.java
@@ -180,8 +180,9 @@
public native void setInnerText(Element elem, String text) /*-{
// Remove all children first.
- elem.innerHTML = '';
-
+ while (elem.firstChild) {
+ elem.removeChild(elem.firstChild);
+ }
// Add a new text node.
if (text != null) {
elem.appendChild($doc.createTextNode(text));
diff --git a/user/src/com/google/gwt/dom/client/DOMImplIE6.java b/user/src/com/google/gwt/dom/client/DOMImplIE6.java
index 6285034..fe4e816 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplIE6.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplIE6.java
@@ -101,4 +101,9 @@
select.add(option);
}
}-*/;
+
+ @Override
+ public native void setInnerText(Element elem, String text) /*-{
+ elem.innerText = text || '';
+ }-*/;
}
diff --git a/user/test/com/google/gwt/user/client/ui/DOMTest.java b/user/test/com/google/gwt/user/client/ui/DOMTest.java
index 40ec2ca..c58977f 100644
--- a/user/test/com/google/gwt/user/client/ui/DOMTest.java
+++ b/user/test/com/google/gwt/user/client/ui/DOMTest.java
@@ -211,31 +211,6 @@
// should be deleted, including any text nodes, for all supported browsers.
assertTrue(getDenormalizedChildCount(tdElem) == 0);
}
-
- /**
- * Tests that {@link DOM#setInnerText(Element, String)} works consistently
- * across browsers with respect to whitespace. Particularly,
- * we want to guarantee that whitespace characters won't be replaced with
- * HTML entities.
- */
- public void testSetInnerTextWhitespace() {
- Element divElem = DOM.createDiv();
- String spaces = " ";
- String whitespace = " \n\t ";
-
- // Block of spaces first. We call trim because it remvoes leading and
- // trailing whitespace characters -- so, if all is well, all of them.
- DOM.setInnerText(divElem, spaces);
- String contents = DOM.getInnerText(divElem);
- String trimmed = contents.trim();
- assertEquals(trimmed, "");
-
- // Now with some assorted whitespace.
- DOM.setInnerText(divElem, whitespace);
- contents = DOM.getInnerText(divElem);
- trimmed = contents.trim();
- assertEquals(trimmed, "");
- }
/**
* Tests the correctness of setting the <code>src</code> attribute on