From e3a57614031bfdb5e83c147c003a3a2014bc455a Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Thu, 3 Nov 2011 10:30:00 +0000 Subject: [PATCH] node list in gquery should be updated each time, so the jsquery exported version can use the exported object as a valid array --- .../src/main/java/com/google/gwt/query/client/GQuery.java | 4 +++- .../main/java/com/google/gwt/query/client/js/JsCache.java | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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 { */ public GQuery setArray(NodeList list) { if (list != null) { - nodeList = list; + nodeList.cast().clear(); int l = list.getLength(); elements = new Element[l]; for (int i = 0; i < l; i++) { elements[i] = list.getItem(i); + nodeList.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 void clear() /*-{ + if (this.length) { + for (i = this.length - 1; i >= 0; i--) + delete this[i]; + this.length = 0; + } + }-*/; + public final native boolean exists(T name) /*-{ return !!this[name]; }-*/; -- 2.39.5