From 18655a7a51ffd79eb9fdd2f5a2fe10bc15d8da43 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Sat, 27 Aug 2011 23:42:40 +0000 Subject: re-factoring --- .../main/java/com/google/gwt/query/client/GQuery.java | 17 +++++++++-------- 1 file 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 { * 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 { * 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 { * 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; } /** -- cgit v1.2.3