From eaa822694aa6c5b7b2d8c8aec1b3961406df81a8 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Wed, 19 Oct 2011 20:22:44 +0000 Subject: [PATCH] Fix tests --- .../java/com/google/gwt/query/client/GQuery.java | 12 +++--------- .../google/gwt/query/client/impl/SelectorEngine.java | 2 +- .../google/gwt/query/client/GQueryEventsTest.java | 6 ++++++ 3 files changed, 10 insertions(+), 10 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 b7937ba8..c91e63ae 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 @@ -449,13 +449,6 @@ public class GQuery implements Lazy { return name != null ? d.get(name) : id; } - /** - * Set element data. - */ - public static Object data(Element e, String key, String value) { - return GQuery.data(e, key, value); - } - /** * Execute a function around each object */ @@ -661,6 +654,7 @@ public class GQuery implements Lazy { /** * The nodeList of matched elements, modify this using setArray */ + // TODO: remove this and use elements, change return type of get() private NodeList nodeList = JavaScriptObject.createArray().cast(); private GQuery previousObject; @@ -1926,11 +1920,11 @@ public class GQuery implements Lazy { break; } EventsListener.rebind(n. cast()); - // GqUi.attachWidget(w); } } - if (newNodes.size() > g.size()) { + // TODO: newNodes.size() > g.size() makes testRebind fail + if (newNodes.size() >= g.size()) { g.setArray(newNodes); } return this; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java index 336a4abe..191aab2a 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngine.java @@ -126,7 +126,7 @@ public class SelectorEngine implements HasSelector { } else if (s.endsWith(":hidden")) { nodes = filterByVisibility(select(s.substring(0, s.length() - 7), ctx), false); } else { - nodes = select(a.get(1) + "[type=" + a.get(2) + "]", ctx); + nodes = select((a.get(1) != null ? a.get(1) : "") + "[type=" + a.get(2) + "]", ctx); } } else { nodes = select(s, ctx); diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java index 20071608..601d9e99 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java @@ -687,12 +687,18 @@ public void testUnDelegateAll2(){ public void testRebind() { final GQuery b = $("

content

"); + assertEquals(1, b.size()); + assertEquals(1, b.get().getLength()); b.click(new Function() { public void f(Element e){ b.css(CSS.COLOR.with(RGBColor.RED)); } }); $(e).append(b); + // TODO: dom manipulations some times modifies gquery nodelist, + // we could remove the nodelist since we maintain a list of elements. + assertEquals(1, b.size()); + assertEquals(1, b.get().getLength()); b.click(); assertEquals("red", $(b).css("color", false)); } -- 2.39.5