From: jdramaix Date: Sat, 1 Feb 2014 15:49:36 +0000 (+0100) Subject: Fix issue #265 X-Git-Tag: gwtquery-project-1.4.3~45^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cbffbdd7cd4a319620583bff71e437cc9e413fe5;p=gwtquery.git Fix issue #265 --- 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 cd75ccd3..cb6d74cf 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 @@ -290,6 +290,7 @@ public class GQuery implements Lazy { System.err.println("GQuery.$(Object o) could not wrap the type : " + o.getClass()); } } + return $(); } @@ -491,6 +492,7 @@ public class GQuery implements Lazy { * Return true if the element b is contained in a. */ public static boolean contains(Element a, Element b) { + maybeInitializeSelectorEngine(); return engine.contains(a, b); } @@ -764,6 +766,12 @@ public class GQuery implements Lazy { return new Deferred(); } + private static void maybeInitializeSelectorEngine() { + if (engine == null) { + engine = new SelectorEngine(); + } + } + private static native void scrollIntoViewImpl(Node n) /*-{ if (n) n.scrollIntoView() @@ -2408,7 +2416,7 @@ public class GQuery implements Lazy { public GQuery has(final Element elem) { return filter(new Predicate() { public boolean f(Element e, int index) { - return engine.contains(e, elem); + return contains(e, elem); } }); } @@ -4137,9 +4145,7 @@ public class GQuery implements Lazy { } private GQuery select(String selector, Node context) { - if (engine == null) { - engine = new SelectorEngine(); - } + maybeInitializeSelectorEngine(); NodeList n = engine.select(selector, context == null ? document : context); currentSelector = selector;