diff options
Diffstat (limited to 'gwtquery-core')
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java | 4 | ||||
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java | 8 |
2 files changed, 11 insertions, 1 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 c91e63ae..28646ea6 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 @@ -46,6 +46,7 @@ import com.google.gwt.query.client.js.JsCache; import com.google.gwt.query.client.js.JsMap;
import com.google.gwt.query.client.js.JsNamedArray;
import com.google.gwt.query.client.js.JsNodeArray;
+import com.google.gwt.query.client.js.JsObjectArray;
import com.google.gwt.query.client.js.JsRegexp;
import com.google.gwt.query.client.js.JsUtils;
import com.google.gwt.query.client.plugins.Effects;
@@ -3717,11 +3718,12 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { */
public GQuery setArray(NodeList<Element> list) {
if (list != null) {
- nodeList = list;
+ nodeList.<JsCache>cast().clear();
int l = list.getLength();
elements = new Element[l];
for (int i = 0; i < l; i++) {
elements[i] = list.getItem(i);
+ nodeList.<JsObjectArray>cast().add(list.getItem(i));
}
}
return this;
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java index 2493055b..2bc9aa45 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java @@ -46,6 +46,14 @@ public class JsCache extends JavaScriptObject { delete this[name]; }-*/; + public final native <T> void clear() /*-{ + if (this.length) { + for (i = this.length - 1; i >= 0; i--) + delete this[i]; + this.length = 0; + } + }-*/; + public final native <T> boolean exists(T name) /*-{ return !!this[name]; }-*/; |