diff options
author | Manolo Carrasco <manolo@apache.org> | 2011-11-03 10:30:00 +0000 |
---|---|---|
committer | Manolo Carrasco <manolo@apache.org> | 2011-11-03 10:30:00 +0000 |
commit | e3a57614031bfdb5e83c147c003a3a2014bc455a (patch) | |
tree | c107e5f3a78a55d3c425ca866923a12261776b1e /gwtquery-core/src | |
parent | 9c1613e2c1a3ae3b9dccd44e66ef1ccfa887546a (diff) | |
download | gwtquery-e3a57614031bfdb5e83c147c003a3a2014bc455a.tar.gz gwtquery-e3a57614031bfdb5e83c147c003a3a2014bc455a.zip |
node list in gquery should be updated each time, so the jsquery exported version can use the exported object as a valid array
Diffstat (limited to 'gwtquery-core/src')
-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]; }-*/; |