From 22079d84f5edcb42b4bc494c2a89a618c906f24f Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Mon, 18 Jul 2011 10:54:37 +0000 Subject: [PATCH] xpath selectors available when using SelectorEngineCssToXPath --- .../java/com/google/gwt/query/client/GQuery.java | 12 ++---------- .../google/gwt/query/client/impl/SelectorEngine.java | 1 + .../gwt/query/client/impl/SelectorEngineNative.java | 4 +++- 3 files changed, 6 insertions(+), 11 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 7ef58ec5..625521c7 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 @@ -138,8 +138,6 @@ public class GQuery implements Lazy { private static SelectorEngine engine; - private static HasSelector xpahtEngine; - private static final int FUNC_PREPEND = 0, FUNC_APPEND = 1, FUNC_AFTER = 2, FUNC_BEFORE = 3; @@ -492,14 +490,8 @@ public class GQuery implements Lazy { if (engine == null) { engine = new SelectorEngine(); } - HasSelector impl = engine; - if (selector.startsWith("./") || selector.startsWith("/")) { - if (xpahtEngine == null) { - impl = xpahtEngine = engine.impl instanceof SelectorEngineCssToXPath ? - engine.impl : new SelectorEngineCssToXPath(); - } - } - NodeList n = impl.select(selector, context == null ? document : context); + + NodeList n = engine.select(selector, context == null ? document : context); JsNodeArray res = copyNodeList(n); currentSelector = selector; 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 386f38ea..8451be10 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 @@ -86,6 +86,7 @@ public class SelectorEngine implements HasSelector { public SelectorEngine() { impl = (SelectorEngineImpl) GWT.create(SelectorEngineImpl.class); + System.out.println("Create SelectorEngineImpl " + impl.getClass().getName()); } public Node getRoot() { diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java index dddcdc37..e020f2a1 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java @@ -26,13 +26,15 @@ import com.google.gwt.dom.client.NodeList; */ public class SelectorEngineNative extends SelectorEngineImpl { - public static String NATIVE_EXCEPTIONS_REGEXP = ".*(\\.//|:contains|!=|:first([^-]|$)|:last([^-]|$)|:even|:odd).*"; + // querySelectorAll unsupported selectors + public static String NATIVE_EXCEPTIONS_REGEXP = "(^[\\./]/.*)|(.*(:contains|!=|:first([^-]|$)|:last([^-]|$)|:even|:odd)).*"; private static HasSelector impl; public SelectorEngineNative() { if (impl == null) { impl = GWT.create(HasSelector.class); + System.out.println("Created HasSelector: " + impl.getClass().getName()); } } -- 2.39.5