-
- expr: {
- "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
- "#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]",
- ":": {
- // Position Checks
- lt: "i<m[3]-0",
- gt: "i>m[3]-0",
- nth: "m[3]-0==i",
- eq: "m[3]-0==i",
- first: "i==0",
- last: "i==r.length-1",
- even: "i%2==0",
- odd: "i%2",
-
- // Child Checks
- "nth-child": "jQuery.sibling(a,m[3]).cur",
- "first-child": "jQuery.sibling(a,0).cur",
- "last-child": "jQuery.sibling(a,0).last",
- "only-child": "jQuery.sibling(a).length==1",
-
- // Parent Checks
- parent: "a.childNodes.length",
- empty: "!a.childNodes.length",
-
- // Text Check
- contains: "jQuery.fn.text.apply([a]).indexOf(m[3])>=0",
-
- // Visibility
- visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
- hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",
-
- // Form attributes
- enabled: "!a.disabled",
- disabled: "a.disabled",
- checked: "a.checked",
- selected: "a.selected || jQuery.attr(a, 'selected')",
-
- // Form elements
- text: "a.type=='text'",
- radio: "a.type=='radio'",
- checkbox: "a.type=='checkbox'",
- file: "a.type=='file'",
- password: "a.type=='password'",
- submit: "a.type=='submit'",
- image: "a.type=='image'",
- reset: "a.type=='reset'",
- button: "a.type=='button'",
- input: "a.nodeName.toLowerCase().match(/input|select|textarea|button/)"
- },
- ".": "jQuery.className.has(a,m[2])",
- "@": {
- "=": "z==m[4]",
- "!=": "z!=m[4]",
- "^=": "z && !z.indexOf(m[4])",
- "$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]",
- "*=": "z && z.indexOf(m[4])>=0",
- "": "z"
- },
- "[": "jQuery.find(m[2],a).length"
- },
-
- token: [
- "\\.\\.|/\\.\\.", "a.parentNode",
- ">|/", "jQuery.sibling(a.firstChild)",
- "\\+", "jQuery.sibling(a).next",
- "~", function(a){
- var r = [];
- var s = jQuery.sibling(a);
- if ( s.n > 0 )
- for ( var i = s.n; i < s.length; i++ )
- r.push( s[i] );
- return r;
- }
- ],
-
- /**
- *
- * @test t( "Element Selector", "div", ["main","foo"] );
- * t( "Element Selector", "body", ["body"] );
- * t( "Element Selector", "html", ["html"] );
- * ok( $("*").size() >= 30, "Element Selector" );
- * t( "Parent Element", "div div", ["foo"] );
- *
- * t( "ID Selector", "#body", ["body"] );
- * t( "ID Selector w/ Element", "body#body", ["body"] );
- * t( "ID Selector w/ Element", "ul#first", [] );
- *
- * 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( "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"] );
- *
- * 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"] );
- * t( "Attribute Exists", "a[@title]", ["google"] );
- * t( "Attribute Exists", "*[@title]", ["google"] );
- * t( "Attribute Exists", "[@title]", ["google"] );
- *
- * t( "Non-existing part of attribute", "[@name*=bla]", [] );
- * t( "Non-existing start of attribute", "[@name^=bla]", [] );
- * t( "Non-existing end of attribute", "[@name$=bla]", [] );
- *
- * 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 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( "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"] );
- *
- * 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","sndp","en","sap"] );
- * t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","sndp","en","sap"] );
- * t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
- *
- * 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( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );
- *
- * t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"] );
- * t( "All Children of ID with no children", "#firstUL/*", [] );
- *
- * 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"] );
- *
- * 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"]);
- *
- * @name $.find
- * @type Array<Element>
- * @private
- * @cat Core
- */
- find: function( t, context ) {
- // Make sure that the context is a DOM Element
- if ( context && context.nodeType == undefined )
- context = null;
-
- // Set the correct context (if none is provided)
- context = context || jQuery.context || document;
-
- if ( t.constructor != String ) return [t];
-
- if ( !t.indexOf("//") ) {
- context = context.documentElement;
- t = t.substr(2,t.length);
- } else if ( !t.indexOf("/") ) {
- context = context.documentElement;
- t = t.substr(1,t.length);
- // FIX Assume the root element is right :(
- if ( t.indexOf("/") >= 1 )
- t = t.substr(t.indexOf("/"),t.length);
- }
-
- var ret = [context];
- var done = [];
- var last = null;
-
- while ( t.length > 0 && last != t ) {
- var r = [];
- last = t;
-
- t = jQuery.trim(t).replace( /^\/\//i, "" );
-
- var foundToken = false;
-
- for ( var i = 0; i < jQuery.token.length; i += 2 ) {
- if ( foundToken ) continue;
-
- var re = new RegExp("^(" + jQuery.token[i] + ")");
- var m = re.exec(t);
-
- if ( m ) {
- r = ret = jQuery.map( ret, jQuery.token[i+1] );
- t = jQuery.trim( t.replace( re, "" ) );
- foundToken = true;
- }
- }
-
- if ( !foundToken ) {
- if ( !t.indexOf(",") || !t.indexOf("|") ) {
- if ( ret[0] == context ) ret.shift();
- done = jQuery.merge( done, ret );
- r = ret = [context];
- t = " " + t.substr(1,t.length);
- } else {
- var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
- var m = re2.exec(t);
-
- if ( m[1] == "#" ) {
- // Ummm, should make this work in all XML docs
- var oid = document.getElementById(m[2]);
- r = ret = oid ? [oid] : [];
- t = t.replace( re2, "" );
- } else {
- if ( !m[2] || m[1] == "." ) m[2] = "*";
-
- for ( var i = 0; i < ret.length; i++ )
- r = jQuery.merge( r,
- m[2] == "*" ?
- jQuery.getAll(ret[i]) :
- ret[i].getElementsByTagName(m[2])
- );
- }
- }
-
- }
-
- if ( t ) {
- var val = jQuery.filter(t,r);
- ret = r = val.r;
- t = jQuery.trim(val.t);
- }
- }
-
- if ( ret && ret[0] == context ) ret.shift();
- done = jQuery.merge( done, ret );
-
- return done;
- },
-
- getAll: function(o,r) {
- r = r || [];
- var s = o.childNodes;
- for ( var i = 0; i < s.length; i++ )
- if ( s[i].nodeType == 1 ) {
- r.push( s[i] );
- jQuery.getAll( s[i], r );
- }
- return r;
- },
-