From 617443d1157cc3769db6d96bf7149278b51768b4 Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Fri, 26 Dec 2014 18:16:01 +0100 Subject: nodeType property error when using selectors like: $(widget) --- .../src/main/java/com/google/gwt/query/client/js/JsUtils.java | 3 +-- .../java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java | 9 +++++++++ 2 files changed, 10 insertions(+), 2 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 65f26cee..d1833d66 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 @@ -19,7 +19,6 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsArrayMixed; -import com.google.gwt.core.client.JsArrayString; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Node; @@ -351,7 +350,7 @@ public class JsUtils { * Check is a javascript object can be cast to an Element */ public static native boolean isElement(Object o) /*-{ - return o && o.nodeType && o.nodeName ? true : false; + return !!o && 'nodeType' in o && 'nodeName' in o; }-*/; /** diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java index b509fa00..287e6440 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java @@ -133,5 +133,14 @@ public class GQueryWidgetsTestGwt extends GWTTestCase { b2.click(); assertEquals("red", $(b1).css("color", false)); } + + public void testSelectorWidget() { + final Button b1 = new Button("click-me"); + RootPanel.get().add(b1); + GQuery g = $(b1); + assertEquals("inline-block", $(b1).css("display")); + g.hide(); + assertEquals("none", $(b1).css("display")); + } } -- cgit v1.2.3 From 447ddbc2d7b69a56540d8b1116913d91b04ec431 Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Fri, 26 Dec 2014 18:48:54 +0100 Subject: Using isVisible for widget selector test. Also removingFromParent Button. --- .../java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java index 287e6440..4d66d771 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java @@ -135,12 +135,13 @@ public class GQueryWidgetsTestGwt extends GWTTestCase { } public void testSelectorWidget() { - final Button b1 = new Button("click-me"); + final Button b1 = new Button("Button click"); RootPanel.get().add(b1); GQuery g = $(b1); - assertEquals("inline-block", $(b1).css("display")); + assertEquals(true, $(b1).isVisible()); g.hide(); - assertEquals("none", $(b1).css("display")); + assertEquals(false, $(b1).isVisible()); + b1.removeFromParent(); } } -- cgit v1.2.3 From 84909924a3af81010bc6c6df933b5c44f125c950 Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Fri, 26 Dec 2014 19:14:36 +0100 Subject: using assertTrue and asserFalse instead of assertEquals(true/false, ...) --- .../test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java index 4d66d771..66e1aab5 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java @@ -138,9 +138,9 @@ public class GQueryWidgetsTestGwt extends GWTTestCase { final Button b1 = new Button("Button click"); RootPanel.get().add(b1); GQuery g = $(b1); - assertEquals(true, $(b1).isVisible()); + assertTrue($(b1).isVisible()); g.hide(); - assertEquals(false, $(b1).isVisible()); + assertFalse($(b1).isVisible()); b1.removeFromParent(); } -- cgit v1.2.3 From 3ef29d689bd6e4377b258ced12c62928d73e674a Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Fri, 26 Dec 2014 21:32:24 +0100 Subject: Using GQuery var instance instead of evaluating selector multiple times. --- .../test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java index 66e1aab5..801992f9 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java @@ -138,9 +138,9 @@ public class GQueryWidgetsTestGwt extends GWTTestCase { final Button b1 = new Button("Button click"); RootPanel.get().add(b1); GQuery g = $(b1); - assertTrue($(b1).isVisible()); + assertTrue(g.isVisible()); g.hide(); - assertFalse($(b1).isVisible()); + assertFalse(g.isVisible()); b1.removeFromParent(); } -- cgit v1.2.3