aboutsummaryrefslogtreecommitdiffstats
path: root/gwtquery-core
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@apache.org>2011-07-12 19:47:44 +0000
committerManolo Carrasco <manolo@apache.org>2011-07-12 19:47:44 +0000
commitb2fe136c07bd889106f7995544a30811d6d9411b (patch)
tree92a7f1bb8939e316b51647ef838a33b7004cbe69 /gwtquery-core
parent75306682d54b504e6e2a915da768efe8b20520f3 (diff)
downloadgwtquery-b2fe136c07bd889106f7995544a30811d6d9411b.tar.gz
gwtquery-b2fe136c07bd889106f7995544a30811d6d9411b.zip
adding :odd :even :first :last pseudo selectors in xpath implementation. Related issue86
Diffstat (limited to 'gwtquery-core')
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java9
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java2
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java2
3 files changed, 10 insertions, 3 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java
index 7426aa29..dad73d9a 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java
@@ -99,7 +99,7 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
// add @ for attrib
"\\[([^@\\]~\\$\\*\\^\\|\\!]+)(=[^\\]]+)?\\]", "[@$1$2]",
// multiple queries
- "\\s*,\\s*", "|",
+ "\\s*,\\s*", "|.//",
// , + ~ >
"\\s*(\\+|~|>)\\s*", "$1",
//* ~ + >
@@ -120,7 +120,12 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
"([\\w\\-\\*]+):only-child", "*[last()=1]/self::$1",
// :empty
"([\\w\\-\\*]+):empty", "$1[not(*) and not(normalize-space())]",
+ // :odd :even, this is intentional since sizzle behaves so
+ ":odd" , ":nth-child(even)",
+ ":even" , ":nth-child(odd)",
+ // :not
"(.+):not\\(([^\\)]*)\\)", rc_Not,
+ // :nth-child
"([a-zA-Z0-9\\_\\-\\*]+):nth-child\\(([^\\)]*)\\)", rc_nth_child,
// :contains(selectors)
":contains\\(([^\\)]*)\\)", "[contains(string(.),'$1')]",
@@ -145,6 +150,8 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
":(enabled)", "[not(@disabled)]",
":(checked)", "[@$1='$1']",
":(disabled)", "[@$1]",
+ ":(first)", "[1]",
+ ":(last)", "[last()]",
// put '*' when tag is omitted
"(^|\\|)(\\[)", "$1*$2",
// Replace escaped dots and spaces
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 7996d107..d69148c4 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,7 +26,7 @@ import com.google.gwt.dom.client.NodeList;
*/
public class SelectorEngineNative extends SelectorEngineImpl {
- public static String NATIVE_EXCEPTIONS_REGEXP = ".*(:contains|!=).*";
+ public static String NATIVE_EXCEPTIONS_REGEXP = ".*(:contains|!=|:first|:last|:even|:odd).*";
private static HasSelector impl;
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java
index bc55b50c..9c405cd6 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java
@@ -29,7 +29,7 @@ import com.google.gwt.dom.client.NodeList;
*/
public class SelectorEngineNativeIE8 extends SelectorEngineSizzleIE {
- public static String NATIVE_EXCEPTIONS_REGEXP = ".*(:contains|!=|:checked|:not|:nth-|:last-|:only-).*";
+ public static String NATIVE_EXCEPTIONS_REGEXP = ".*(:contains|!=|:checked|:not|:nth-|:only-|:first|:last|:even|:odd).*";
public NodeList<Element> select(String selector, Node ctx) {
if (!SelectorEngine.hasQuerySelector || selector.matches(NATIVE_EXCEPTIONS_REGEXP)) {