aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@apache.org>2011-08-27 23:42:40 +0000
committerManolo Carrasco <manolo@apache.org>2011-08-27 23:42:40 +0000
commit18655a7a51ffd79eb9fdd2f5a2fe10bc15d8da43 (patch)
tree6f3f56d4c840fad892bc2494a98779306c2c93c0
parent9267072869a9373262145a44bd9b1f69b4a085ff (diff)
downloadgwtquery-18655a7a51ffd79eb9fdd2f5a2fe10bc15d8da43.tar.gz
gwtquery-18655a7a51ffd79eb9fdd2f5a2fe10bc15d8da43.zip
re-factoring
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java
index 8ef7911a..a51ef266 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java
@@ -920,7 +920,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* Set a single property to a value, on all matched elements.
*/
public GQuery attr(String key, boolean value) {
- String val = value ? "true" : null;
+ String val = value ? key : null;
for (Element e : elements) {
setElementAttribute(e, key, val);
}
@@ -931,13 +931,11 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* Set a single property to a value, on all matched elements.
*/
public GQuery attr(String key, String value) {
- boolean remove = value == null;
+ if (value == null) {
+ return removeAttr(key);
+ }
for (Element e : elements) {
- if (remove) {
- e.removeAttribute(key);
- } else {
- e.setAttribute(key, value);
- }
+ e.setAttribute(key, value);
}
return this;
}
@@ -3093,7 +3091,10 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* Remove the named attribute from every element in the matched set.
*/
public GQuery removeAttr(String key) {
- return attr(key, (String)null);
+ for (Element e : elements) {
+ e.removeAttribute(key);
+ }
+ return this;
}
/**