Changeset 1593
- Timestamp:
- 03/25/07 19:02:31 (2 years ago)
- Location:
- trunk/jquery
- Files:
-
- 3 modified
-
build/test/index.html (modified) (1 diff)
-
src/selector/selector.js (modified) (7 diffs)
-
src/selector/selectorTest.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/jquery/build/test/index.html
r1586 r1593 84 84 <span id="utf8class1" class="台北Táiběi 台北"></span> 85 85 <span id="utf8class2" class="台北"></span> 86 <span id="foo:bar" class="foo:bar"></span> 87 <span id="test.foo[5]bar" class="test.foo[5]bar"></span> 86 88 </form> 87 89 <b id="floatTest">Float test.</b> -
trunk/jquery/src/selector/selector.js
r1579 r1593 68 68 parse: [ 69 69 // Match: [@value='test'], [@foo] 70 /^\[ *(@)([\w-]+) *([!*$^=]*) *('?"?)(.*?)\4 *\]/ i,70 /^\[ *(@)([\w-]+) *([!*$^=]*) *('?"?)(.*?)\4 *\]/, 71 71 72 72 // Match: [div], [div p] … … 74 74 75 75 // Match: :contains('foo') 76 /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/ i,76 /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/, 77 77 78 78 // Match: :even, :last-chlid, #id, .class 79 /^([:.#]*)((?:[\w\u0128-\uFFFF*-]|\\.)+)/ i79 /^([:.#]*)((?:[\w\u0128-\uFFFF*-]|\\.)+)/ 80 80 ], 81 81 … … 149 149 // An attempt at speeding up child selectors that 150 150 // point to a specific element tag 151 var re = /^[\/>]\s*([\w*-]+)/ i;151 var re = /^[\/>]\s*([\w*-]+)/; 152 152 var m = re.exec(t); 153 153 … … 169 169 // Attempt to match each, individual, token in 170 170 // the specified order 171 var re = jQuery.token[i] ;171 var re = jQuery.token[i], fn = jQuery.token[i+1]; 172 172 var m = re.exec(t); 173 173 … … 175 175 if ( m ) { 176 176 // Map it against the token's handler 177 r = ret = jQuery.map( ret, jQuery.isFunction( jQuery.token[i+1] ) ? 178 jQuery.token[i+1] : 179 function(a){ return eval(jQuery.token[i+1]); }); 177 r = ret = jQuery.map( ret, jQuery.isFunction( fn ) ? 178 fn : new Function( "a", "return " + fn ) ); 180 179 181 180 // And remove the token … … 206 205 } else { 207 206 // Optomize for the case nodeName#idName 208 var re2 = /^(\w+)(#)((?:[\w\u0128-\uFFFF*-]|\\.)+)/ i;207 var re2 = /^(\w+)(#)((?:[\w\u0128-\uFFFF*-]|\\.)+)/; 209 208 var m = re2.exec(t); 210 209 … … 216 215 // Otherwise, do a traditional filter check for 217 216 // ID, class, and element selectors 218 re2 = /^([#.]?)((?:[\w\u0128-\uFFFF*-]|\\.)*)/ i;217 re2 = /^([#.]?)((?:[\w\u0128-\uFFFF*-]|\\.)*)/; 219 218 m = re2.exec(t); 220 219 } -
trunk/jquery/src/selector/selectorTest.js
r1592 r1593 153 153 t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] ); 154 154 t( "Empty", "ul:empty", ["firstUL"] ); 155 t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name" ] );155 t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name","length"] ); 156 156 t( "Disabled UI Element", "input:disabled", ["text2"] ); 157 157 t( "Checked UI Element", "input:checked", ["radio2","check1"] ); … … 171 171 t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] ); 172 172 t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] ); 173 t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name" ] );173 t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name","length"] ); 174 174 t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] ); 175 175 176 t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3" ] );176 t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3", "length"] ); 177 177 t( "Form element :radio", ":radio", ["radio1", "radio2"] ); 178 178 t( "Form element :checkbox", ":checkbox", ["check1", "check2"] ); 179 t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name" ] );179 t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name", "length"] ); 180 180 t( "Form element :radio:checked", ":radio:checked", ["radio2"] ); 181 181 t( "Form element :checkbox:checked", ":checkbox:checked", ["check1"] ); … … 196 196 t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] ); 197 197 t( "Parent Axis", "//p/..", ["main","foo"] ); 198 t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe"," sndp","en","sap"] );199 t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe"," sndp","en","sap"] );198 t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","lengthtest","sndp","en","sap"] ); 199 t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","lengthtest","sndp","en","sap"] ); 200 200 t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] ); 201 201
