]> source.dussan.org Git - gwtquery.git/commitdiff
use the shorthand \w in css2xpat regex
authorManolo Carrasco <manolo@apache.org>
Wed, 2 Jun 2010 11:25:44 +0000 (11:25 +0000)
committerManolo Carrasco <manolo@apache.org>
Wed, 2 Jun 2010 11:25:44 +0000 (11:25 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java

index cd6c506c5c1dbf5518b20b03d85e19a68bc5c365..83f5bb5f603590f74c72082de02f4dba49837666 100644 (file)
@@ -89,51 +89,50 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl {
     // , + ~ >\r
     "\\s*(\\+|~|>)\\s*", "$1",\r
     //* ~ + >\r
-    "([a-zA-Z0-9_\\-\\*])~([a-zA-Z0-9_\\-\\*])", "$1/following-sibling::$2",\r
-    "([a-zA-Z0-9_\\-\\*])\\+([a-zA-Z0-9_\\-\\*])", "$1/following-sibling::*[1]/self::$2",\r
-    "([a-zA-Z0-9_\\-\\*])>([a-zA-Z0-9_\\-\\*])", "$1/$2",\r
+    "([\\w\\-\\*])~([\\w\\-\\*])", "$1/following-sibling::$2",\r
+    "([\\w\\-\\*])\\+([\\w\\-\\*])", "$1/following-sibling::*[1]/self::$2",\r
+    "([\\w\\-\\*])>([\\w\\-\\*])", "$1/$2",\r
     // all unescaped stuff escaped\r
     "\\[([^=]+)=([^'|\"][^\\]]*)\\]", "[$1='$2']",\r
     // all descendant or self to \r
-    "(^|[^a-zA-Z0-9_\\-\\*])(#|\\.)([a-zA-Z0-9_\\-]+)", "$1*$2$3",\r
+    "(^|[^\\w\\-\\*])(#|\\.)([\\w\\-]+)", "$1*$2$3",\r
     "([\\>\\+\\|\\~\\,\\s])([a-zA-Z\\*]+)", "$1//$2",\r
     "\\s+//", "//",\r
     // :first-child\r
-    "([a-zA-Z0-9_\\-\\*]+):first-child", "*[1]/self::$1",\r
+    "([\\w\\-\\*]+):first-child", "*[1]/self::$1",\r
     // :last-child\r
-    "([a-zA-Z0-9_\\-\\*]+):last-child", "$1[not(following-sibling::*)]",\r
+    "([\\w\\-\\*]+):last-child", "$1[not(following-sibling::*)]",\r
     // :only-child\r
-    "([a-zA-Z0-9_\\-\\*]+):only-child", "*[last()=1]/self::$1",\r
+    "([\\w\\-\\*]+):only-child", "*[last()=1]/self::$1",\r
     // :empty\r
-    "([a-zA-Z0-9_\\-\\*]+):empty", "$1[not(*) and not(normalize-space())]",\r
+    "([\\w\\-\\*]+):empty", "$1[not(*) and not(normalize-space())]",\r
     "(.+):not\\(([^\\)]*)\\)", rc_Not,\r
     "([a-zA-Z0-9\\_\\-\\*]+):nth-child\\(([^\\)]*)\\)", rc_nth_child,\r
     // :contains(selectors)\r
     ":contains\\(([^\\)]*)\\)", "[contains(string(.),'$1')]",\r
     // |= attrib\r
-    "\\[([a-zA-Z0-9_\\-]+)\\|=([^\\]]+)\\]", "[@$1=$2 or starts-with(@$1,concat($2,'-'))]",\r
+    "\\[([\\w\\-]+)\\|=([^\\]]+)\\]", "[@$1=$2 or starts-with(@$1,concat($2,'-'))]",\r
     // *= attrib\r
-    "\\[([a-zA-Z0-9_\\-]+)\\*=([^\\]]+)\\]", "[contains(@$1,$2)]",\r
+    "\\[([\\w\\-]+)\\*=([^\\]]+)\\]", "[contains(@$1,$2)]",\r
     // ~= attrib\r
-    "\\[([a-zA-Z0-9_\\-]+)~=([^\\]]+)\\]", "[contains(concat(' ',normalize-space(@$1),' '),concat(' ',$2,' '))]",\r
+    "\\[([\\w\\-]+)~=([^\\]]+)\\]", "[contains(concat(' ',normalize-space(@$1),' '),concat(' ',$2,' '))]",\r
     // ^= attrib\r
-    "\\[([a-zA-Z0-9_\\-]+)\\^=([^\\]]+)\\]", "[starts-with(@$1,$2)]",\r
+    "\\[([\\w\\-]+)\\^=([^\\]]+)\\]", "[starts-with(@$1,$2)]",\r
     // $= attrib\r
-    "\\[([a-zA-Z0-9_\\-]+)\\$=([^\\]]+)\\]", rc_$Attr,\r
+    "\\[([\\w\\-]+)\\$=([^\\]]+)\\]", rc_$Attr,\r
     // != attrib\r
-    "\\[([a-zA-Z0-9_\\-]+)\\!=([^\\]]+)\\]", "[not(@$1) or @$1!=$2]",\r
+    "\\[([\\w\\-]+)\\!=([^\\]]+)\\]", "[not(@$1) or @$1!=$2]",\r
     // ids and classes\r
-    "#([a-zA-Z0-9_\\-]+)", "[@id='$1']",\r
-    "\\.([a-zA-Z0-9_\\-]+)", "[contains(concat(' ',normalize-space(@class),' '),' $1 ')]",\r
+    "#([\\w\\-]+)", "[@id='$1']",\r
+    "\\.([\\w\\-]+)", "[contains(concat(' ',normalize-space(@class),' '),' $1 ')]",\r
     // normalize multiple filters\r
     "\\]\\[([^\\]]+)", " and ($1)",\r
     // tag:pseudo\r
-    ":enabled", "[not(@disabled)]",\r
-    ":checked", "[@checked='checked']",\r
+    ":(enabled)", "[not(@disabled)]",\r
+    ":(checked)", "[@$1='$1']",\r
     ":(disabled)", "[@$1]",\r
     // put '*' when tag is omitted\r
-    "^\\[", "*[",\r
-    "\\|\\[", "|*["\r
+    "(^|\\|)(\\[)", "$1*$2"\r
     };\r
   \r
   public static SelectorEngineCssToXPath getInstance() {\r