]> source.dussan.org Git - gwtquery.git/commitdiff
adding :odd :even :first :last pseudo selectors in xpath implementation. Related...
authorManolo Carrasco <manolo@apache.org>
Tue, 12 Jul 2011 19:47:44 +0000 (19:47 +0000)
committerManolo Carrasco <manolo@apache.org>
Tue, 12 Jul 2011 19:47:44 +0000 (19:47 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNative.java
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineNativeIE8.java

index 7426aa293f00de143281367c21d1b9e62b0afe0f..dad73d9a06b906ef81ec05dab93962293ca2df9c 100644 (file)
@@ -99,7 +99,7 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
     // add @ for attrib\r
     "\\[([^@\\]~\\$\\*\\^\\|\\!]+)(=[^\\]]+)?\\]", "[@$1$2]",\r
     // multiple queries\r
-    "\\s*,\\s*", "|",\r
+    "\\s*,\\s*", "|.//",\r
     // , + ~ >\r
     "\\s*(\\+|~|>)\\s*", "$1",\r
     //* ~ + >\r
@@ -120,7 +120,12 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
     "([\\w\\-\\*]+):only-child", "*[last()=1]/self::$1",\r
     // :empty\r
     "([\\w\\-\\*]+):empty", "$1[not(*) and not(normalize-space())]",\r
+    // :odd :even, this is intentional since sizzle behaves so\r
+    ":odd" , ":nth-child(even)",\r
+    ":even" , ":nth-child(odd)",\r
+    // :not\r
     "(.+):not\\(([^\\)]*)\\)", rc_Not,\r
+    // :nth-child\r
     "([a-zA-Z0-9\\_\\-\\*]+):nth-child\\(([^\\)]*)\\)", rc_nth_child,\r
     // :contains(selectors)\r
     ":contains\\(([^\\)]*)\\)", "[contains(string(.),'$1')]",\r
@@ -145,6 +150,8 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
     ":(enabled)", "[not(@disabled)]",\r
     ":(checked)", "[@$1='$1']",\r
     ":(disabled)", "[@$1]",\r
+    ":(first)", "[1]",\r
+    ":(last)", "[last()]",\r
     // put '*' when tag is omitted\r
     "(^|\\|)(\\[)", "$1*$2",\r
     // Replace escaped dots and spaces\r
index 7996d107ef68fb55aabf62afe5bdbde659e2d268..d69148c4e67cc1b7376e48b7000abe22bc1a4beb 100644 (file)
@@ -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;
   
index bc55b50c08208d5a1efce9c484fa3dc131cbe8b2..9c405cd6e95a435e26c0e115eeb5083cf20645bc 100644 (file)
@@ -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)) {