Added UTF8 Selector support (#1001) and fixed infinite selector loops (#1025). You...
authorJohn Resig <jeresig@gmail.com>
Sun, 25 Mar 2007 00:58:19 +0000 (00:58 +0000)
committerJohn Resig <jeresig@gmail.com>
Sun, 25 Mar 2007 00:58:19 +0000 (00:58 +0000)
build/test/index.html
src/selector/selector.js
src/selector/selectorTest.js

index 0425570..8fead08 100644 (file)
@@ -1,5 +1,6 @@
 <html id="html">
 <head>
+       <meta http-equiv="Content-Type" content="text/css; charset=utf-8" />
        <title>jQuery Test Suite</title>
        <link rel="Stylesheet" media="screen" href="data/testsuite.css" />
        <script type="text/javascript" src="../dist/jquery.js"></script>
                                <param name="p1" value="x1" />
                                <param name="p2" value="x2" />
                        </object>
+                       
+                       <span id="台北Táiběi"></span>
+                       <span id="台北" lang="中文"></span>
+                       <span id="utf8class1" class="台北Táiběi 台北"></span>
+                       <span id="utf8class2" class="台北"></span>
                </form>
                <b id="floatTest">Float test.</b>
                <iframe id="iframe"></iframe>
index 3bd6b34..9d36ca7 100644 (file)
@@ -67,16 +67,16 @@ jQuery.extend({
        // The regular expressions that power the parsing engine
        parse: [
                // Match: [@value='test'], [@foo]
-               /^\[ *(@)([a-z0-9_-]*) *([!*$^=]*) *('?"?)(.*?)\4 *\]/i,
+               /^\[ *(@)([\w-]+) *([!*$^=]*) *('?"?)(.*?)\4 *\]/i,
 
                // Match: [div], [div p]
                /^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,
 
                // Match: :contains('foo')
-               /^(:)([a-z0-9_-]*)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/i,
+               /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/i,
 
-               // Match: :even, :last-chlid
-               /^([:.#]*)([a-z0-9_*-]*)/i
+               // Match: :even, :last-chlid, #id, .class
+               /^([:.#]*)([\w\u0128-\uFFFF*-]+)/i
        ],
 
        token: [
@@ -134,7 +134,7 @@ jQuery.extend({
                }
 
                // Initialize the search
-               var ret = [context], done = [], last = null;
+               var ret = [context], done = [], last;
 
                // Continue while a selector expression exists, and while
                // we're no longer looping upon ourselves
@@ -142,13 +142,13 @@ jQuery.extend({
                        var r = [];
                        last = t;
 
-                       t = jQuery.trim(t).replace( /^\/\//i, "" );
+                       t = jQuery.trim(t).replace( /^\/\//, "" );
 
                        var foundToken = false;
 
                        // An attempt at speeding up child selectors that
                        // point to a specific element tag
-                       var re = /^[\/>]\s*([a-z0-9*-]+)/i;
+                       var re = /^[\/>]\s*([\w*-]+)/i;
                        var m = re.exec(t);
 
                        if ( m ) {
@@ -205,7 +205,7 @@ jQuery.extend({
 
                                } else {
                                        // Optomize for the case nodeName#idName
-                                       var re2 = /^([a-z0-9_-]+)(#)([a-z0-9\\*_-]*)/i;
+                                       var re2 = /^(\w+)(#)([\w\u0128-\uFFFF*-]+)/i;
                                        var m = re2.exec(t);
                                        
                                        // Re-organize the results, so that they're consistent
@@ -215,21 +215,21 @@ jQuery.extend({
                                        } else {
                                                // Otherwise, do a traditional filter check for
                                                // ID, class, and element selectors
-                                               re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
+                                               re2 = /^([#.]?)([\w\u0128-\uFFFF*-]*)/i;
                                                m = re2.exec(t);
                                        }
 
-                                       var last = ret[ret.length-1];
+                                       var elem = ret[ret.length-1];
 
                                        // Try to do a global search by ID, where we can
-                                       if ( m[1] == "#" && last && last.getElementById ) {
+                                       if ( m[1] == "#" && elem && elem.getElementById ) {
                                                // Optimization for HTML document case
-                                               var oid = last.getElementById(m[2]);
+                                               var oid = elem.getElementById(m[2]);
                                                
                                                // Do a quick check for the existence of the actual ID attribute
                                                // to avoid selecting by the name attribute in IE
                                                if ( jQuery.browser.msie && oid && oid.id != m[2] )
-                                                       oid = jQuery('[@id="'+m[2]+'"]', last)[0];
+                                                       oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
 
                                                // Do a quick check for node name (where applicable) so
                                                // that div#foo searches will be really fast
@@ -292,8 +292,14 @@ jQuery.extend({
                        }
                }
 
+               // An error occurred with the selector;
+               // just return an empty set instead
+               if ( t )
+                       ret = [];
+
                // Remove the root context
-               if ( ret && ret[0] == context ) ret.shift();
+               if ( ret && ret[0] == context )
+                       ret.shift();
 
                // And combine the results
                done = jQuery.merge( done, ret );
@@ -302,8 +308,11 @@ jQuery.extend({
        },
 
        filter: function(t,r,not) {
+               var last;
+
                // Look for common filter expressions
-               while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
+               while ( t  && t != last ) {
+                       last = t;
 
                        var p = jQuery.parse, m;
 
@@ -325,6 +334,9 @@ jQuery.extend({
                                }
                        });
 
+                       if ( !m )
+                               continue;
+
                        // :not() is a special case that can be optimized by
                        // keeping it out of the expression list
                        if ( m[1] == ":" && m[2] == "not" )
index fea247e..5cd3b23 100644 (file)
-module("selector");\r
-\r
-test("expressions - element", function() {\r
-       expect(6);\r
-       ok( $("*").size() >= 30, "Select all" );\r
-       t( "Element Selector", "div", ["main","foo"] );\r
-       t( "Element Selector", "body", ["body"] );\r
-       t( "Element Selector", "html", ["html"] );\r
-       t( "Parent Element", "div div", ["foo"] );\r
-       ok( $("param", "#object1").length == 2, "Object/param as context" );\r
-});\r
-\r
-test("expressions - id", function() {\r
-       expect(13);\r
-       t( "ID Selector", "#body", ["body"] );\r
-       t( "ID Selector w/ Element", "body#body", ["body"] );\r
-       t( "ID Selector w/ Element", "ul#first", [] );\r
-       t( "ID selector with existing ID descendant", "#firstp #simon1", ["simon1"] );\r
-       t( "ID selector with non-existant descendant", "#firstp #foobar", [] );\r
-       \r
-       t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] );  // bug #267\r
-       t( "ID Selector, not an ancestor ID", "#form  #first", [] );\r
-       t( "ID Selector, not a child ID", "#form > #option1a", [] );\r
-       \r
-       t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"] );\r
-       t( "All Children of ID with no children", "#firstUL/*", [] );\r
-       \r
-       $('<a name="tName1">tName1 A</a><a name="tName2">tName2 A</a><div id="tName1">tName1 Div</div>').appendTo('#main');\r
-       ok( $("#tName1")[0].id == 'tName1', "ID selector with same value for a name attribute" );\r
-       ok( $("#tName2").length == 0, "ID selector non-existing but name attribute on an A tag" );\r
-       \r
-       t( "ID selector with non-existant ancestor", "#asdfasdf #foobar", [] ); // bug #986\r
-});\r
-\r
-\r
-test("expressions - class", function() {\r
-       expect(4);\r
-       t( "Class Selector", ".blog", ["mark","simon"] );\r
-       t( "Class Selector", ".blog.link", ["simon"] );\r
-       t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );\r
-       t( "Parent Class Selector", "p .blog", ["mark","simon"] );\r
-});\r
-\r
-test("expressions - multiple", function() {\r
-       expect(4);\r
-       t( "Comma Support", "a.blog, div", ["mark","simon","main","foo"] );\r
-       t( "Comma Support", "a.blog , div", ["mark","simon","main","foo"] );\r
-       t( "Comma Support", "a.blog ,div", ["mark","simon","main","foo"] );\r
-       t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );\r
-});\r
-\r
-test("expressions - child and adjacent", function() {\r
-       expect(14);\r
-       t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );\r
-       t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );\r
-       t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );\r
-       t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );\r
-       t( "Child w/ Class", "p > a.blog", ["mark","simon"] );\r
-       t( "All Children", "code > *", ["anchor1","anchor2"] );\r
-       t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );\r
-       t( "Adjacent", "a + a", ["groups"] );\r
-       t( "Adjacent", "a +a", ["groups"] );\r
-       t( "Adjacent", "a+ a", ["groups"] );\r
-       t( "Adjacent", "a+a", ["groups"] );\r
-       t( "Adjacent", "p + p", ["ap","en","sap"] );\r
-       t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );\r
-       t( "First Child", "p:first-child", ["firstp","sndp"] );\r
-});\r
-\r
-test("expressions - attributes", function() {\r
-       expect(19);\r
-       t( "Attribute Exists", "a[@title]", ["google"] );\r
-       t( "Attribute Exists", "*[@title]", ["google"] );\r
-       t( "Attribute Exists", "[@title]", ["google"] );\r
-       \r
-       t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );\r
-       t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );\r
-       t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );\r
-       t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );\r
-       t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );\r
-       t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );\r
-       \r
-       t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );\r
-       t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );\r
-       t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );\r
-       \r
-       t("Select options via [@selected]", "#select1 option[@selected]", ["option1a"] );\r
-       t("Select options via [@selected]", "#select2 option[@selected]", ["option2d"] );\r
-       t("Select options via [@selected]", "#select3 option[@selected]", ["option3b", "option3c"] );\r
-       \r
-       t( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );\r
-       \r
-       t( ":not() Existing attribute", "select:not([@multiple])", ["select1", "select2"]);\r
-       t( ":not() Equals attribute", "select:not([@name=select1])", ["select2", "select3"]);\r
-       t( ":not() Equals quoted attribute", "select:not([@name='select1'])", ["select2", "select3"]);\r
-});\r
-\r
-test("expressions - pseudo (:) selctors", function() {\r
-       expect(30);\r
-       t( "First Child", "p:first-child", ["firstp","sndp"] );\r
-       t( "Last Child", "p:last-child", ["sap"] );\r
-       t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );\r
-       t( "Empty", "ul:empty", ["firstUL"] );\r
-       t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name"] );\r
-       t( "Disabled UI Element", "input:disabled", ["text2"] );\r
-       t( "Checked UI Element", "input:checked", ["radio2","check1"] );\r
-       t( "Selected Option Element", "option:selected", ["option1a","option2d","option3b","option3c"] );\r
-       t( "Text Contains", "a:contains('Google')", ["google","groups"] );\r
-       t( "Text Contains", "a:contains('Google Groups')", ["groups"] );\r
-       t( "Element Preceded By", "p ~ div", ["foo"] );\r
-       t( "Not", "a.blog:not(.link)", ["mark"] );\r
-       \r
-       t( "nth Element", "p:nth(1)", ["ap"] );\r
-       t( "First Element", "p:first", ["firstp"] );\r
-       t( "Last Element", "p:last", ["first"] );\r
-       t( "Even Elements", "p:even", ["firstp","sndp","sap"] );\r
-       t( "Odd Elements", "p:odd", ["ap","en","first"] );\r
-       t( "Position Equals", "p:eq(1)", ["ap"] );\r
-       t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );\r
-       t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );\r
-       t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );\r
-       t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );\r
-       t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );\r
-       \r
-       t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3"] );\r
-       t( "Form element :radio", ":radio", ["radio1", "radio2"] );\r
-       t( "Form element :checkbox", ":checkbox", ["check1", "check2"] );\r
-       t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name"] );\r
-       t( "Form element :radio:checked", ":radio:checked", ["radio2"] );\r
-       t( "Form element :checkbox:checked", ":checkbox:checked", ["check1"] );\r
-       t( "Form element :checkbox:checked, :radio:checked", ":checkbox:checked, :radio:checked", ["check1", "radio2"] );\r
-});\r
-\r
-test("expressions - basic xpath", function() {\r
-       expect(15);\r
-       ok( jQuery.find("//*").length >= 30, "All Elements (//*)" );\r
-       t( "All Div Elements", "//div", ["main","foo"] );\r
-       t( "Absolute Path", "/html/body", ["body"] );\r
-       t( "Absolute Path w/ *", "/* /body", ["body"] );\r
-       t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );\r
-       t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );\r
-       t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );\r
-       t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );\r
-       t( "Attribute Exists", "//a[@title]", ["google"] );\r
-       t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );\r
-       t( "Parent Axis", "//p/..", ["main","foo"] );\r
-       t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","sndp","en","sap"] );\r
-       t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","sndp","en","sap"] );\r
-       t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );\r
-       \r
-       $("#foo").each(function() {\r
-               isSet( $("/p", this).get(), q("sndp", "en", "sap"), "Check XPath context" );\r
-       });\r
-});\r
+module("selector");
+
+test("element", function() {
+       expect(6);
+       ok( $("*").size() >= 30, "Select all" );
+       t( "Element Selector", "div", ["main","foo"] );
+       t( "Element Selector", "body", ["body"] );
+       t( "Element Selector", "html", ["html"] );
+       t( "Parent Element", "div div", ["foo"] );
+       ok( $("param", "#object1").length == 2, "Object/param as context" );
+});
+
+test("broken", function() {
+       expect(7);
+       t( "Broken Selector", "[", [] );
+       t( "Broken Selector", "(", [] );
+       t( "Broken Selector", "{", [] );
+       t( "Broken Selector", "<", [] );
+       t( "Broken Selector", "()", [] );
+       t( "Broken Selector", "<>", [] );
+       t( "Broken Selector", "{}", [] );
+});
+
+test("id", function() {
+       expect(17);
+       t( "ID Selector", "#body", ["body"] );
+       t( "ID Selector w/ Element", "body#body", ["body"] );
+       t( "ID Selector w/ Element", "ul#first", [] );
+       t( "ID selector with existing ID descendant", "#firstp #simon1", ["simon1"] );
+       t( "ID selector with non-existant descendant", "#firstp #foobar", [] );
+       t( "ID selector using UTF8", "#台北Táiběi", ["台北Táiběi"] );
+       t( "Multiple ID selectors using UTF8", "#台北Táiběi, #台北", ["台北Táiběi","台北"] );
+       t( "Descendant ID selector using UTF8", "div #台北", ["台北"] );
+       t( "Child ID selector using UTF8", "form > #台北", ["台北"] );
+       
+       t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] );  // bug #267
+       t( "ID Selector, not an ancestor ID", "#form  #first", [] );
+       t( "ID Selector, not a child ID", "#form > #option1a", [] );
+       
+       t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"] );
+       t( "All Children of ID with no children", "#firstUL/*", [] );
+       
+       $('<a name="tName1">tName1 A</a><a name="tName2">tName2 A</a><div id="tName1">tName1 Div</div>').appendTo('#main');
+       ok( $("#tName1")[0].id == 'tName1', "ID selector with same value for a name attribute" );
+       ok( $("#tName2").length == 0, "ID selector non-existing but name attribute on an A tag" );
+       
+       t( "ID selector with non-existant ancestor", "#asdfasdf #foobar", [] ); // bug #986
+});
+
+test("class", function() {
+       expect(10);
+       t( "Class Selector", ".blog", ["mark","simon"] );
+       t( "Class Selector", ".blog.link", ["simon"] );
+       t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
+       t( "Parent Class Selector", "p .blog", ["mark","simon"] );
+       
+       t( "Class selector using UTF8", ".台北Táiběi", ["utf8class1"] );
+       t( "Class selector using UTF8", ".台北", ["utf8class1","utf8class2"] );
+       t( "Class selector using UTF8", ".台北Táiběi.台北", ["utf8class1"] );
+       t( "Class selector using UTF8", ".台北Táiběi, .台北", ["utf8class1","utf8class2"] );
+       t( "Descendant class selector using UTF8", "div .台北Táiběi", ["utf8class1"] );
+       t( "Child class selector using UTF8", "form > .台北Táiběi", ["utf8class1"] );
+});
+
+test("multiple", function() {
+       expect(4);
+       t( "Comma Support", "a.blog, div", ["mark","simon","main","foo"] );
+       t( "Comma Support", "a.blog , div", ["mark","simon","main","foo"] );
+       t( "Comma Support", "a.blog ,div", ["mark","simon","main","foo"] );
+       t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );
+});
+
+test("child and adjacent", function() {
+       expect(14);
+       t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
+       t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
+       t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
+       t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
+       t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
+       t( "All Children", "code > *", ["anchor1","anchor2"] );
+       t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
+       t( "Adjacent", "a + a", ["groups"] );
+       t( "Adjacent", "a +a", ["groups"] );
+       t( "Adjacent", "a+ a", ["groups"] );
+       t( "Adjacent", "a+a", ["groups"] );
+       t( "Adjacent", "p + p", ["ap","en","sap"] );
+       t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
+       t( "First Child", "p:first-child", ["firstp","sndp"] );
+});
+
+test("attributes", function() {
+       expect(20);
+       t( "Attribute Exists", "a[@title]", ["google"] );
+       t( "Attribute Exists", "*[@title]", ["google"] );
+       t( "Attribute Exists", "[@title]", ["google"] );
+       
+       t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );
+       t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );
+       t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );
+       t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );
+       t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );
+       t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );
+       
+       t( "Attribute selector using UTF8", "span[@lang=中文]", ["台北"] );
+       
+       t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );
+       t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
+       t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );
+       
+       t("Select options via [@selected]", "#select1 option[@selected]", ["option1a"] );
+       t("Select options via [@selected]", "#select2 option[@selected]", ["option2d"] );
+       t("Select options via [@selected]", "#select3 option[@selected]", ["option3b", "option3c"] );
+       
+       t( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );
+       
+       t( ":not() Existing attribute", "select:not([@multiple])", ["select1", "select2"]);
+       t( ":not() Equals attribute", "select:not([@name=select1])", ["select2", "select3"]);
+       t( ":not() Equals quoted attribute", "select:not([@name='select1'])", ["select2", "select3"]);
+});
+
+test("pseudo (:) selctors", function() {
+       expect(30);
+       t( "First Child", "p:first-child", ["firstp","sndp"] );
+       t( "Last Child", "p:last-child", ["sap"] );
+       t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
+       t( "Empty", "ul:empty", ["firstUL"] );
+       t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name"] );
+       t( "Disabled UI Element", "input:disabled", ["text2"] );
+       t( "Checked UI Element", "input:checked", ["radio2","check1"] );
+       t( "Selected Option Element", "option:selected", ["option1a","option2d","option3b","option3c"] );
+       t( "Text Contains", "a:contains('Google')", ["google","groups"] );
+       t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
+       t( "Element Preceded By", "p ~ div", ["foo"] );
+       t( "Not", "a.blog:not(.link)", ["mark"] );
+       
+       t( "nth Element", "p:nth(1)", ["ap"] );
+       t( "First Element", "p:first", ["firstp"] );
+       t( "Last Element", "p:last", ["first"] );
+       t( "Even Elements", "p:even", ["firstp","sndp","sap"] );
+       t( "Odd Elements", "p:odd", ["ap","en","first"] );
+       t( "Position Equals", "p:eq(1)", ["ap"] );
+       t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
+       t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
+       t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
+       t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );
+       t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );
+       
+       t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3"] );
+       t( "Form element :radio", ":radio", ["radio1", "radio2"] );
+       t( "Form element :checkbox", ":checkbox", ["check1", "check2"] );
+       t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name"] );
+       t( "Form element :radio:checked", ":radio:checked", ["radio2"] );
+       t( "Form element :checkbox:checked", ":checkbox:checked", ["check1"] );
+       t( "Form element :checkbox:checked, :radio:checked", ":checkbox:checked, :radio:checked", ["check1", "radio2"] );
+});
+
+test("basic xpath", function() {
+       expect(15);
+       ok( jQuery.find("//*").length >= 30, "All Elements (//*)" );
+       t( "All Div Elements", "//div", ["main","foo"] );
+       t( "Absolute Path", "/html/body", ["body"] );
+       t( "Absolute Path w/ *", "/* /body", ["body"] );
+       t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );
+       t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );
+       t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );
+       t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );
+       t( "Attribute Exists", "//a[@title]", ["google"] );
+       t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );
+       t( "Parent Axis", "//p/..", ["main","foo"] );
+       t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","sndp","en","sap"] );
+       t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","sndp","en","sap"] );
+       t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
+       
+       $("#foo").each(function() {
+               isSet( $("/p", this).get(), q("sndp", "en", "sap"), "Check XPath context" );
+       });
+});