aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java12
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java2
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java28
3 files changed, 21 insertions, 21 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
index d77c8cb9..693ff708 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
@@ -281,7 +281,7 @@ public class JsUtils {
* Returns the owner document element of an element.
*/
public static Document getOwnerDocument(Node n) {
- return n == null ? null : n.getNodeType() == Node.DOCUMENT_NODE
+ return n == null || !isElement(n) ? null : n.getNodeType() == Node.DOCUMENT_NODE
? n.<Document> cast() : n.getOwnerDocument();
}
@@ -343,7 +343,7 @@ public class JsUtils {
* Check is a javascript object can be cast to an Element
*/
public static boolean isElement(JavaScriptObject o) {
- return hasProperty(o, "nodeName");
+ return hasProperty(o, "nodeType") && hasProperty(o, "nodeName");
}
/**
@@ -387,7 +387,7 @@ public class JsUtils {
/**
* Load an external javascript library. The inserted script replaces the
* element with the given id in the document.
- *
+ *
* @deprecated use {@link com.google.gwt.query.client.plugins.ajax.Ajax#loadScript(String)}
*/
@Deprecated
@@ -445,10 +445,10 @@ public class JsUtils {
/**
* Call via jsni any arbitrary function present in a Javascript object.
- *
+ *
* It's thought for avoiding to create jsni methods to call external functions and
* facilitate the writing of js wrappers.
- *
+ *
* Example
* <pre>
* // Create a svg node in our document.
@@ -456,7 +456,7 @@ public class JsUtils {
* // Append it to the dom
* $(svg).appendTo(document);
* </pre>
- *
+ *
* @param o the javascript object where the function is.
* @param meth the literal name of the function to call.
* @param args an array with the arguments to pass to the function.
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
index 5d09fea8..26f96fc4 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
@@ -40,7 +40,7 @@ public class Events extends GQuery {
* Don't apply events on text and comment nodes !!
*/
private static boolean isEventCapable(Node n) {
- return JsUtils.isWindow(n) || n.getNodeType() != 3 && n.getNodeType() != 8;
+ return JsUtils.isWindow(n) || JsUtils.isElement(n) && n.getNodeType() != 3 && n.getNodeType() != 8;
}
public Events(GQuery gq) {
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java
index 82d1ff74..91c899a5 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java
@@ -82,14 +82,14 @@ public class Deferred implements Promise.Deferred {
settle(type, oldArgs);
}
}
-
+
private void settle(int action, Object... args) {
if (action == DONE) dfd.resolve(args);
if (action == FAIL) dfd.reject(args);
- if (action == PROGRESS) dfd.notify(args);
+ if (action == PROGRESS) dfd.notify(args);
}
}
-
+
protected com.google.gwt.query.client.plugins.deferred.Deferred dfd;
/**
@@ -142,11 +142,11 @@ public class Deferred implements Promise.Deferred {
public Promise always(Function... f) {
return done(f).fail(f);
}
-
+
public Promise and(Function f) {
return then(f);
}
-
+
public Promise done(Function... f) {
dfd.resolve.add(f);
return this;
@@ -156,11 +156,11 @@ public class Deferred implements Promise.Deferred {
dfd.reject.add(f);
return this;
}
-
+
public Promise or(final Function f) {
return then(true, null, f);
- }
-
+ }
+
public Promise pipe(Function... f) {
return then(f);
}
@@ -181,7 +181,7 @@ public class Deferred implements Promise.Deferred {
progress(new ThenFunction(newDfd, f, PROGRESS, continueFlow));
return newDfd.promise();
}
-
+
public Promise then(final Function... f) {
return then(false, f);
}
@@ -273,7 +273,7 @@ public class Deferred implements Promise.Deferred {
}
return when(p);
}
-
+
private static Promise makePromise(final Object o) {
if (o instanceof Promise) {
return (Promise)o;
@@ -289,7 +289,7 @@ public class Deferred implements Promise.Deferred {
};
}
}
-
+
public static Promise when(Promise... d) {
final int n = d.length;
switch (n) {
@@ -334,7 +334,7 @@ public class Deferred implements Promise.Deferred {
* Call the progressCallbacks on a Deferred object with the given args.
*/
public Deferred notify(Object... o) {
- notify.fire(o);
+ if (state == PENDING) notify.fire(o);
return this;
}
@@ -352,7 +352,7 @@ public class Deferred implements Promise.Deferred {
* Reject a Deferred object and call any failCallbacks with the given args.
*/
public Deferred reject(Object... o) {
- reject.fire(o);
+ if (state == PENDING) reject.fire(o);
return this;
}
@@ -360,7 +360,7 @@ public class Deferred implements Promise.Deferred {
* Resolve a Deferred object and call any doneCallbacks with the given args.
*/
public Deferred resolve(Object... o) {
- resolve.fire(o);
+ if (state == PENDING) resolve.fire(o);
return this;
}