]> source.dussan.org Git - gwtquery.git/commitdiff
Fix gQuery failing when managing non native element objects
authorManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>
Mon, 9 Dec 2013 18:24:16 +0000 (19:24 +0100)
committerManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>
Mon, 9 Dec 2013 18:24:16 +0000 (19:24 +0100)
gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java

index d77c8cb9d008048c610c76cfe977e58dd66bc342..693ff708dd6126b3a0e438897538b55acf3e7595 100644 (file)
@@ -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.
index 5d09fea85ce855cd003b0ca62ab1188a454f56c1..26f96fc42a0d0efe2fed690f7f2b1889c80d91bc 100644 (file)
@@ -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) {