From bdb5ce4f3c1f86e7e86163c178c1826c4147979e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20Carrasco=20Mo=C3=B1ino?= Date: Mon, 9 Dec 2013 19:24:16 +0100 Subject: [PATCH] Fix gQuery failing when managing non native element objects --- .../java/com/google/gwt/query/client/js/JsUtils.java | 12 ++++++------ .../com/google/gwt/query/client/plugins/Events.java | 2 +- 2 files changed, 7 insertions(+), 7 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. 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 *
    *  // Create a svg node in our document.
@@ -456,7 +456,7 @@ public class JsUtils {
    *  // Append it to the dom
    *  $(svg).appendTo(document);
    * 
- * + * * @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) { -- 2.39.5