Andrey Korzhevskiy has uploaded a new change for review.
https://gwt-review.googlesource.com/3071
Change subject: Add hasClassName method in com.google.gwt.dom.client.Element
......................................................................
Add hasClassName method in com.google.gwt.dom.client.Element
Change-Id: Ibe9a1aacb3530c9c688ab321e64f6dff95eb2b20
---
M user/src/com/google/gwt/dom/client/Element.java
M user/test/com/google/gwt/dom/client/ElementTest.java
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/user/src/com/google/gwt/dom/client/Element.java
b/user/src/com/google/gwt/dom/client/Element.java
index dd0abd5..c9c9592 100644
--- a/user/src/com/google/gwt/dom/client/Element.java
+++ b/user/src/com/google/gwt/dom/client/Element.java
@@ -89,7 +89,7 @@
* @see #setClassName(String)
*/
public final boolean addClassName(String className) {
- className = checkClassName(className);
+ className = trimClassName(className);
// Get the current style string.
String oldClassName = getClassName();
@@ -114,7 +114,7 @@
* @return <code>true</code> if this element has the specified class name
*/
public final boolean hasClassName(String className) {
- className = checkClassName(className);
+ className = trimClassName(className);
int idx = indexOfName(getClassName(), className);
return idx != -1;
}
@@ -533,7 +533,7 @@
* @see #setClassName(String)
*/
public final boolean removeClassName(String className) {
- className = checkClassName(className);
+ className = trimClassName(className);
// Get the current style string.
String oldStyle = getClassName();
@@ -588,17 +588,15 @@
}
/**
- * Checks if className is valid and trims it.
+ * Trim class name.
*
* @param className a non-empty string
* @return trimmed class name string
*/
- static String checkClassName(String className) {
+ private static String trimClassName(String className) {
assert (className != null) : "Unexpectedly null class name";
-
className = className.trim();
- assert (className.length() != 0) : "Unexpectedly empty class name";
-
+ assert !className.isEmpty() : "Unexpectedly empty class name";
return className;
}
diff --git a/user/test/com/google/gwt/dom/client/ElementTest.java
b/user/test/com/google/gwt/dom/client/ElementTest.java
index b79a784..907f736 100644
--- a/user/test/com/google/gwt/dom/client/ElementTest.java
+++ b/user/test/com/google/gwt/dom/client/ElementTest.java
@@ -70,6 +70,7 @@
assertTrue(div.hasClassName("foo"));
div.removeClassName("foo");
assertFalse(div.hasClassName("foo"));
+ assertTrue(div.hasClassName("bar"));
}
public void testIndexOfName() {
--
To view, visit https://gwt-review.googlesource.com/3071
To unsubscribe, visit https://gwt-review.googlesource.com/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe9a1aacb3530c9c688ab321e64f6dff95eb2b20
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Andrey Korzhevskiy <[email protected]>
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.