Fixed some more bugs with the test suite, made some minor file size tweaks to the...
authorJohn Resig <jeresig@gmail.com>
Sun, 25 Mar 2007 19:02:31 +0000 (19:02 +0000)
committerJohn Resig <jeresig@gmail.com>
Sun, 25 Mar 2007 19:02:31 +0000 (19:02 +0000)
build/test/index.html
src/selector/selector.js
src/selector/selectorTest.js

index b798a09..10e74cc 100644 (file)
                        <span id="台北" lang="中文"></span>
                        <span id="utf8class1" class="台北Táiběi 台北"></span>
                        <span id="utf8class2" class="台北"></span>
+                       <span id="foo:bar" class="foo:bar"></span>
+                       <span id="test.foo[5]bar" class="test.foo[5]bar"></span>
                </form>
                <b id="floatTest">Float test.</b>
-               <iframe id="iframe" name="iframe"></iframe>\r
-               <form id="lengthtest">\r
-                       <input type="text" id="length" name="test">\r
+               <iframe id="iframe" name="iframe"></iframe>
+               <form id="lengthtest">
+                       <input type="text" id="length" name="test">
                </form>
        </div>
        </dl>
index cc37584..b754d42 100644 (file)
@@ -67,16 +67,16 @@ jQuery.extend({
        // The regular expressions that power the parsing engine
        parse: [
                // Match: [@value='test'], [@foo]
-               /^\[ *(@)([\w-]+) *([!*$^=]*) *('?"?)(.*?)\4 *\]/i,
+               /^\[ *(@)([\w-]+) *([!*$^=]*) *('?"?)(.*?)\4 *\]/,
 
                // Match: [div], [div p]
                /^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,
 
                // Match: :contains('foo')
-               /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/i,
+               /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
 
                // Match: :even, :last-chlid, #id, .class
-               /^([:.#]*)((?:[\w\u0128-\uFFFF*-]|\\.)+)/i
+               /^([:.#]*)((?:[\w\u0128-\uFFFF*-]|\\.)+)/
        ],
 
        token: [
@@ -148,7 +148,7 @@ jQuery.extend({
 
                        // An attempt at speeding up child selectors that
                        // point to a specific element tag
-                       var re = /^[\/>]\s*([\w*-]+)/i;
+                       var re = /^[\/>]\s*([\w*-]+)/;
                        var m = re.exec(t);
 
                        if ( m ) {
@@ -168,15 +168,14 @@ jQuery.extend({
                                for ( var i = 0; i < jQuery.token.length; i += 2 ) {
                                        // Attempt to match each, individual, token in
                                        // the specified order
-                                       var re = jQuery.token[i];
+                                       var re = jQuery.token[i], fn = jQuery.token[i+1];
                                        var m = re.exec(t);
 
                                        // If the token match was found
                                        if ( m ) {
                                                // Map it against the token's handler
-                                               r = ret = jQuery.map( ret, jQuery.isFunction( jQuery.token[i+1] ) ?
-                                                       jQuery.token[i+1] :
-                                                       function(a){ return eval(jQuery.token[i+1]); });
+                                               r = ret = jQuery.map( ret, jQuery.isFunction( fn ) ?
+                                                       fn : new Function( "a", "return " + fn ) );
 
                                                // And remove the token
                                                t = jQuery.trim( t.replace( re, "" ) );
@@ -205,7 +204,7 @@ jQuery.extend({
 
                                } else {
                                        // Optomize for the case nodeName#idName
-                                       var re2 = /^(\w+)(#)((?:[\w\u0128-\uFFFF*-]|\\.)+)/i;
+                                       var re2 = /^(\w+)(#)((?:[\w\u0128-\uFFFF*-]|\\.)+)/;
                                        var m = re2.exec(t);
                                        
                                        // Re-organize the results, so that they're consistent
@@ -215,7 +214,7 @@ jQuery.extend({
                                        } else {
                                                // Otherwise, do a traditional filter check for
                                                // ID, class, and element selectors
-                                               re2 = /^([#.]?)((?:[\w\u0128-\uFFFF*-]|\\.)*)/i;
+                                               re2 = /^([#.]?)((?:[\w\u0128-\uFFFF*-]|\\.)*)/;
                                                m = re2.exec(t);
                                        }
 
index 8200595..857d9c7 100644 (file)
@@ -152,7 +152,7 @@ test("pseudo (:) selectors", function() {
        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( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name","length"] );
        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"] );
@@ -170,13 +170,13 @@ test("pseudo (:) selectors", function() {
        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 Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name","length"] );
        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 :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3", "length"] );
        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 :text", ":text", ["text1", "text2", "hidden2", "name", "length"] );
        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"] );
@@ -195,8 +195,8 @@ test("basic xpath", function() {
        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( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","lengthtest","sndp","en","sap"] );
+       t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","lengthtest","sndp","en","sap"] );
        t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
        
        $("#foo").each(function() {