3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
15 * This is code is also distributed under MIT license for use
\r
16 * with jQuery and prototype JavaScript libraries.
\r
18 <div id="cls-Ext.DomQuery"></div>/**
\r
19 * @class Ext.DomQuery
\r
20 Provides high performance selector/xpath processing by compiling queries into reusable functions. New pseudo classes and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in).
\r
22 DomQuery supports most of the <a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215/#selectors">CSS3 selectors spec</a>, along with some custom selectors and basic XPath.</p>
\r
25 All selectors, attribute filters and pseudos below can be combined infinitely in any order. For example "div.foo:nth-child(odd)[@foo=bar].bar:first" would be a perfectly valid selector. Node filters are processed in the order in which they appear, which allows you to optimize your queries for your document structure.
\r
27 <h4>Element Selectors:</h4>
\r
29 <li> <b>*</b> any element</li>
\r
30 <li> <b>E</b> an element with the tag E</li>
\r
31 <li> <b>E F</b> All descendent elements of E that have the tag F</li>
\r
32 <li> <b>E > F</b> or <b>E/F</b> all direct children elements of E that have the tag F</li>
\r
33 <li> <b>E + F</b> all elements with the tag F that are immediately preceded by an element with the tag E</li>
\r
34 <li> <b>E ~ F</b> all elements with the tag F that are preceded by a sibling element with the tag E</li>
\r
36 <h4>Attribute Selectors:</h4>
\r
37 <p>The use of @ and quotes are optional. For example, div[@foo='bar'] is also a valid attribute selector.</p>
\r
39 <li> <b>E[foo]</b> has an attribute "foo"</li>
\r
40 <li> <b>E[foo=bar]</b> has an attribute "foo" that equals "bar"</li>
\r
41 <li> <b>E[foo^=bar]</b> has an attribute "foo" that starts with "bar"</li>
\r
42 <li> <b>E[foo$=bar]</b> has an attribute "foo" that ends with "bar"</li>
\r
43 <li> <b>E[foo*=bar]</b> has an attribute "foo" that contains the substring "bar"</li>
\r
44 <li> <b>E[foo%=2]</b> has an attribute "foo" that is evenly divisible by 2</li>
\r
45 <li> <b>E[foo!=bar]</b> has an attribute "foo" that does not equal "bar"</li>
\r
47 <h4>Pseudo Classes:</h4>
\r
49 <li> <b>E:first-child</b> E is the first child of its parent</li>
\r
50 <li> <b>E:last-child</b> E is the last child of its parent</li>
\r
51 <li> <b>E:nth-child(<i>n</i>)</b> E is the <i>n</i>th child of its parent (1 based as per the spec)</li>
\r
52 <li> <b>E:nth-child(odd)</b> E is an odd child of its parent</li>
\r
53 <li> <b>E:nth-child(even)</b> E is an even child of its parent</li>
\r
54 <li> <b>E:only-child</b> E is the only child of its parent</li>
\r
55 <li> <b>E:checked</b> E is an element that is has a checked attribute that is true (e.g. a radio or checkbox) </li>
\r
56 <li> <b>E:first</b> the first E in the resultset</li>
\r
57 <li> <b>E:last</b> the last E in the resultset</li>
\r
58 <li> <b>E:nth(<i>n</i>)</b> the <i>n</i>th E in the resultset (1 based)</li>
\r
59 <li> <b>E:odd</b> shortcut for :nth-child(odd)</li>
\r
60 <li> <b>E:even</b> shortcut for :nth-child(even)</li>
\r
61 <li> <b>E:contains(foo)</b> E's innerHTML contains the substring "foo"</li>
\r
62 <li> <b>E:nodeValue(foo)</b> E contains a textNode with a nodeValue that equals "foo"</li>
\r
63 <li> <b>E:not(S)</b> an E element that does not match simple selector S</li>
\r
64 <li> <b>E:has(S)</b> an E element that has a descendent that matches simple selector S</li>
\r
65 <li> <b>E:next(S)</b> an E element whose next sibling matches simple selector S</li>
\r
66 <li> <b>E:prev(S)</b> an E element whose previous sibling matches simple selector S</li>
\r
68 <h4>CSS Value Selectors:</h4>
\r
70 <li> <b>E{display=none}</b> css value "display" that equals "none"</li>
\r
71 <li> <b>E{display^=none}</b> css value "display" that starts with "none"</li>
\r
72 <li> <b>E{display$=none}</b> css value "display" that ends with "none"</li>
\r
73 <li> <b>E{display*=none}</b> css value "display" that contains the substring "none"</li>
\r
74 <li> <b>E{display%=2}</b> css value "display" that is evenly divisible by 2</li>
\r
75 <li> <b>E{display!=none}</b> css value "display" that does not equal "none"</li>
\r
79 Ext.DomQuery = function(){
\r
84 trimRe = /^\s+|\s+$/g,
\r
85 tplRe = /\{(\d+)\}/g,
\r
86 modeRe = /^(\s?[\/>+~]\s?|\s|$)/,
\r
87 tagTokenRe = /^(#)?([\w-\*]+)/,
\r
88 nthRe = /(\d*)n\+?(\d*)/,
\r
90 // This is for IE MSXML which does not support expandos.
\r
91 // IE runs the same speed using setAttribute, however FF slows way down
\r
92 // and Safari completely fails so they need to continue to use expandos.
\r
93 isIE = window.ActiveXObject ? true : false,
\r
94 isOpera = Ext.isOpera,
\r
97 // this eval is stop the compressor from
\r
98 // renaming the variable to something shorter
\r
99 eval("var batch = 30803;");
\r
101 function child(p, index){
\r
105 if(n.nodeType == 1){
\r
116 while((n = n.nextSibling) && n.nodeType != 1);
\r
121 while((n = n.previousSibling) && n.nodeType != 1);
\r
125 function children(d){
\r
126 var n = d.firstChild, ni = -1,
\r
129 nx = n.nextSibling;
\r
130 if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
\r
133 n.nodeIndex = ++ni;
\r
140 function byClassName(c, a, v){
\r
144 var r = [], ri = -1, cn;
\r
145 for(var i = 0, ci; ci = c[i]; i++){
\r
146 if((' '+ci.className+' ').indexOf(v) != -1){
\r
153 function attrValue(n, attr){
\r
154 if(!n.tagName && typeof n.length != "undefined"){
\r
163 if(attr == "class" || attr == "className"){
\r
164 return n.className;
\r
166 return n.getAttribute(attr) || n[attr];
\r
170 function getNodes(ns, mode, tagName){
\r
171 var result = [], ri = -1, cs;
\r
175 tagName = tagName || "*";
\r
176 if(typeof ns.getElementsByTagName != "undefined"){
\r
180 for(var i = 0, ni; ni = ns[i]; i++){
\r
181 cs = ni.getElementsByTagName(tagName);
\r
182 for(var j = 0, ci; ci = cs[j]; j++){
\r
186 }else if(mode == "/" || mode == ">"){
\r
187 var utag = tagName.toUpperCase();
\r
188 for(var i = 0, ni, cn; ni = ns[i]; i++){
\r
189 cn = isOpera ? ni.childNodes : (ni.children || ni.childNodes);
\r
190 for(var j = 0, cj; cj = cn[j]; j++){
\r
191 if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
\r
196 }else if(mode == "+"){
\r
197 var utag = tagName.toUpperCase();
\r
198 for(var i = 0, n; n = ns[i]; i++){
\r
199 while((n = n.nextSibling) && n.nodeType != 1);
\r
200 if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){
\r
204 }else if(mode == "~"){
\r
205 var utag = tagName.toUpperCase();
\r
206 for(var i = 0, n; n = ns[i]; i++){
\r
207 while((n = n.nextSibling)){
\r
208 if (n.nodeName == utag || n.nodeName == tagName || tagName == '*'){
\r
217 function concat(a, b){
\r
219 return a.concat(b);
\r
221 for(var i = 0, l = b.length; i < l; i++){
\r
222 a[a.length] = b[i];
\r
227 function byTag(cs, tagName){
\r
228 if(cs.tagName || cs == document){
\r
234 var r = [], ri = -1;
\r
235 tagName = tagName.toLowerCase();
\r
236 for(var i = 0, ci; ci = cs[i]; i++){
\r
237 if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){
\r
244 function byId(cs, attr, id){
\r
245 if(cs.tagName || cs == document){
\r
251 var r = [], ri = -1;
\r
252 for(var i = 0,ci; ci = cs[i]; i++){
\r
253 if(ci && ci.id == id){
\r
261 function byAttribute(cs, attr, value, op, custom){
\r
265 f = Ext.DomQuery.operators[op];
\r
266 for(var i = 0, ci; ci = cs[i]; i++){
\r
267 if(ci.nodeType != 1){
\r
272 a = Ext.DomQuery.getStyle(ci, attr);
\r
274 else if(attr == "class" || attr == "className"){
\r
276 }else if(attr == "for"){
\r
278 }else if(attr == "href"){
\r
279 a = ci.getAttribute("href", 2);
\r
281 a = ci.getAttribute(attr);
\r
283 if((f && f(a, value)) || (!f && a)){
\r
290 function byPseudo(cs, name, value){
\r
291 return Ext.DomQuery.pseudos[name](cs, value);
\r
294 function nodupIEXml(cs){
\r
297 cs[0].setAttribute("_nodup", d);
\r
299 for(var i = 1, len = cs.length; i < len; i++){
\r
301 if(!c.getAttribute("_nodup") != d){
\r
302 c.setAttribute("_nodup", d);
\r
306 for(var i = 0, len = cs.length; i < len; i++){
\r
307 cs[i].removeAttribute("_nodup");
\r
312 function nodup(cs){
\r
316 var len = cs.length, c, i, r = cs, cj, ri = -1;
\r
317 if(!len || typeof cs.nodeType != "undefined" || len == 1){
\r
320 if(isIE && typeof cs[0].selectSingleNode != "undefined"){
\r
321 return nodupIEXml(cs);
\r
325 for(i = 1; c = cs[i]; i++){
\r
330 for(var j = 0; j < i; j++){
\r
333 for(j = i+1; cj = cs[j]; j++){
\r
334 if(cj._nodup != d){
\r
345 function quickDiffIEXml(c1, c2){
\r
348 for(var i = 0, len = c1.length; i < len; i++){
\r
349 c1[i].setAttribute("_qdiff", d);
\r
351 for(var i = 0, len = c2.length; i < len; i++){
\r
352 if(c2[i].getAttribute("_qdiff") != d){
\r
353 r[r.length] = c2[i];
\r
356 for(var i = 0, len = c1.length; i < len; i++){
\r
357 c1[i].removeAttribute("_qdiff");
\r
362 function quickDiff(c1, c2){
\r
363 var len1 = c1.length,
\r
369 if(isIE && c1[0].selectSingleNode){
\r
370 return quickDiffIEXml(c1, c2);
\r
372 for(var i = 0; i < len1; i++){
\r
375 for(var i = 0, len = c2.length; i < len; i++){
\r
376 if(c2[i]._qdiff != d){
\r
377 r[r.length] = c2[i];
\r
383 function quickId(ns, mode, root, id){
\r
385 var d = root.ownerDocument || root;
\r
386 return d.getElementById(id);
\r
388 ns = getNodes(ns, mode, "*");
\r
389 return byId(ns, null, id);
\r
393 getStyle : function(el, name){
\r
394 return Ext.fly(el).getStyle(name);
\r
396 <div id="method-Ext.DomQuery-compile"></div>/**
\r
397 * Compiles a selector/xpath query into a reusable function. The returned function
\r
398 * takes one parameter "root" (optional), which is the context node from where the query should start.
\r
399 * @param {String} selector The selector/xpath query
\r
400 * @param {String} type (optional) Either "select" (the default) or "simple" for a simple selector match
\r
401 * @return {Function}
\r
403 compile : function(path, type){
\r
404 type = type || "select";
\r
406 var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"],
\r
407 q = path, mode, lq,
\r
408 tk = Ext.DomQuery.matchers,
\r
411 // accept leading mode switch
\r
412 lmode = q.match(modeRe);
\r
414 if(lmode && lmode[1]){
\r
415 fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";';
\r
416 q = q.replace(lmode[1], "");
\r
418 // strip leading slashes
\r
419 while(path.substr(0, 1)=="/"){
\r
420 path = path.substr(1);
\r
423 while(q && lq != q){
\r
425 var tm = q.match(tagTokenRe);
\r
426 if(type == "select"){
\r
429 fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
\r
431 fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
\r
433 q = q.replace(tm[0], "");
\r
434 }else if(q.substr(0, 1) != '@'){
\r
435 fn[fn.length] = 'n = getNodes(n, mode, "*");';
\r
440 fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
\r
442 fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
\r
444 q = q.replace(tm[0], "");
\r
447 while(!(mm = q.match(modeRe))){
\r
448 var matched = false;
\r
449 for(var j = 0; j < tklen; j++){
\r
451 var m = q.match(t.re);
\r
453 fn[fn.length] = t.select.replace(tplRe, function(x, i){
\r
456 q = q.replace(m[0], "");
\r
461 // prevent infinite loop on bad selector
\r
463 throw 'Error parsing selector, parsing failed at "' + q + '"';
\r
467 fn[fn.length] = 'mode="'+mm[1].replace(trimRe, "")+'";';
\r
468 q = q.replace(mm[1], "");
\r
471 fn[fn.length] = "return nodup(n);\n}";
\r
476 <div id="method-Ext.DomQuery-select"></div>/**
\r
477 * Selects a group of elements.
\r
478 * @param {String} selector The selector/xpath query (can be a comma separated list of selectors)
\r
479 * @param {Node} root (optional) The start of the query (defaults to document).
\r
480 * @return {Array} An Array of DOM elements which match the selector. If there are
\r
481 * no matches, and empty Array is returned.
\r
483 select : function(path, root, type){
\r
484 if(!root || root == document){
\r
487 if(typeof root == "string"){
\r
488 root = document.getElementById(root);
\r
490 var paths = path.split(","),
\r
492 for(var i = 0, len = paths.length; i < len; i++){
\r
493 var p = paths[i].replace(trimRe, "");
\r
495 cache[p] = Ext.DomQuery.compile(p);
\r
497 throw p + " is not a valid selector";
\r
500 var result = cache[p](root);
\r
501 if(result && result != document){
\r
502 results = results.concat(result);
\r
505 if(paths.length > 1){
\r
506 return nodup(results);
\r
511 <div id="method-Ext.DomQuery-selectNode"></div>/**
\r
512 * Selects a single element.
\r
513 * @param {String} selector The selector/xpath query
\r
514 * @param {Node} root (optional) The start of the query (defaults to document).
\r
515 * @return {Element} The DOM element which matched the selector.
\r
517 selectNode : function(path, root){
\r
518 return Ext.DomQuery.select(path, root)[0];
\r
521 <div id="method-Ext.DomQuery-selectValue"></div>/**
\r
522 * Selects the value of a node, optionally replacing null with the defaultValue.
\r
523 * @param {String} selector The selector/xpath query
\r
524 * @param {Node} root (optional) The start of the query (defaults to document).
\r
525 * @param {String} defaultValue
\r
528 selectValue : function(path, root, defaultValue){
\r
529 path = path.replace(trimRe, "");
\r
530 if(!valueCache[path]){
\r
531 valueCache[path] = Ext.DomQuery.compile(path, "select");
\r
533 var n = valueCache[path](root),
\r
535 n = n[0] ? n[0] : n;
\r
536 v = (n && n.firstChild ? n.firstChild.nodeValue : null);
\r
537 return ((v === null||v === undefined||v==='') ? defaultValue : v);
\r
540 <div id="method-Ext.DomQuery-selectNumber"></div>/**
\r
541 * Selects the value of a node, parsing integers and floats. Returns the defaultValue, or 0 if none is specified.
\r
542 * @param {String} selector The selector/xpath query
\r
543 * @param {Node} root (optional) The start of the query (defaults to document).
\r
544 * @param {Number} defaultValue
\r
547 selectNumber : function(path, root, defaultValue){
\r
548 var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
\r
549 return parseFloat(v);
\r
552 <div id="method-Ext.DomQuery-is"></div>/**
\r
553 * Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child)
\r
554 * @param {String/HTMLElement/Array} el An element id, element or array of elements
\r
555 * @param {String} selector The simple selector to test
\r
556 * @return {Boolean}
\r
558 is : function(el, ss){
\r
559 if(typeof el == "string"){
\r
560 el = document.getElementById(el);
\r
562 var isArray = Ext.isArray(el),
\r
563 result = Ext.DomQuery.filter(isArray ? el : [el], ss);
\r
564 return isArray ? (result.length == el.length) : (result.length > 0);
\r
567 <div id="method-Ext.DomQuery-filter"></div>/**
\r
568 * Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child)
\r
569 * @param {Array} el An array of elements to filter
\r
570 * @param {String} selector The simple selector to test
\r
571 * @param {Boolean} nonMatches If true, it returns the elements that DON'T match
\r
572 * the selector instead of the ones that match
\r
573 * @return {Array} An Array of DOM elements which match the selector. If there are
\r
574 * no matches, and empty Array is returned.
\r
576 filter : function(els, ss, nonMatches){
\r
577 ss = ss.replace(trimRe, "");
\r
578 if(!simpleCache[ss]){
\r
579 simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
\r
581 var result = simpleCache[ss](els);
\r
582 return nonMatches ? quickDiff(result, els) : result;
\r
585 <div id="prop-Ext.DomQuery-matchers"></div>/**
\r
586 * Collection of matching regular expressions and code snippets.
\r
590 select: 'n = byClassName(n, null, " {1} ");'
\r
592 re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
\r
593 select: 'n = byPseudo(n, "{1}", "{2}");'
\r
595 re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
\r
596 select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
\r
599 select: 'n = byId(n, null, "{1}");'
\r
602 select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
\r
606 <div id="method-Ext.DomQuery-operators"></div>/**
\r
607 * Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
\r
608 * New operators can be added as long as the match the format <i>c</i>= where <i>c</i> is any character other than space, > <.
\r
611 "=" : function(a, v){
\r
614 "!=" : function(a, v){
\r
617 "^=" : function(a, v){
\r
618 return a && a.substr(0, v.length) == v;
\r
620 "$=" : function(a, v){
\r
621 return a && a.substr(a.length-v.length) == v;
\r
623 "*=" : function(a, v){
\r
624 return a && a.indexOf(v) !== -1;
\r
626 "%=" : function(a, v){
\r
627 return (a % v) == 0;
\r
629 "|=" : function(a, v){
\r
630 return a && (a == v || a.substr(0, v.length+1) == v+'-');
\r
632 "~=" : function(a, v){
\r
633 return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
\r
637 <div id="prop-Ext.DomQuery-pseudos"></div>/**
\r
638 * <p>Object hash of "pseudo class" filter functions which are used when filtering selections. Each function is passed
\r
639 * two parameters:</p><div class="mdetail-params"><ul>
\r
640 * <li><b>c</b> : Array<div class="sub-desc">An Array of DOM elements to filter.</div></li>
\r
641 * <li><b>v</b> : String<div class="sub-desc">The argument (if any) supplied in the selector.</div></li>
\r
643 * <p>A filter function returns an Array of DOM elements which conform to the pseudo class.</p>
\r
644 * <p>In addition to the provided pseudo classes listed above such as <code>first-child</code> and <code>nth-child</code>,
\r
645 * developers may add additional, custom psuedo class filters to select elements according to application-specific requirements.</p>
\r
646 * <p>For example, to filter <code><a></code> elements to only return links to <i>external</i> resources:</p>
\r
648 Ext.DomQuery.pseudos.external = function(c, v){
\r
649 var r = [], ri = -1;
\r
650 for(var i = 0, ci; ci = c[i]; i++){
\r
651 // Include in result set only if it's a link to an external resource
\r
652 if(ci.hostname != location.hostname){
\r
658 * Then external links could be gathered with the following statement:<code><pre>
\r
659 var externalLinks = Ext.select("a:external");
\r
663 "first-child" : function(c){
\r
664 var r = [], ri = -1, n;
\r
665 for(var i = 0, ci; ci = n = c[i]; i++){
\r
666 while((n = n.previousSibling) && n.nodeType != 1);
\r
674 "last-child" : function(c){
\r
675 var r = [], ri = -1, n;
\r
676 for(var i = 0, ci; ci = n = c[i]; i++){
\r
677 while((n = n.nextSibling) && n.nodeType != 1);
\r
685 "nth-child" : function(c, a) {
\r
686 var r = [], ri = -1,
\r
687 m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a),
\r
688 f = (m[1] || 1) - 0, l = m[2] - 0;
\r
689 for(var i = 0, n; n = c[i]; i++){
\r
690 var pn = n.parentNode;
\r
691 if (batch != pn._batch) {
\r
693 for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
\r
694 if(cn.nodeType == 1){
\r
695 cn.nodeIndex = ++j;
\r
701 if (l == 0 || n.nodeIndex == l){
\r
704 } else if ((n.nodeIndex + l) % f == 0){
\r
712 "only-child" : function(c){
\r
713 var r = [], ri = -1;;
\r
714 for(var i = 0, ci; ci = c[i]; i++){
\r
715 if(!prev(ci) && !next(ci)){
\r
722 "empty" : function(c){
\r
723 var r = [], ri = -1;
\r
724 for(var i = 0, ci; ci = c[i]; i++){
\r
725 var cns = ci.childNodes, j = 0, cn, empty = true;
\r
726 while(cn = cns[j]){
\r
728 if(cn.nodeType == 1 || cn.nodeType == 3){
\r
740 "contains" : function(c, v){
\r
741 var r = [], ri = -1;
\r
742 for(var i = 0, ci; ci = c[i]; i++){
\r
743 if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
\r
750 "nodeValue" : function(c, v){
\r
751 var r = [], ri = -1;
\r
752 for(var i = 0, ci; ci = c[i]; i++){
\r
753 if(ci.firstChild && ci.firstChild.nodeValue == v){
\r
760 "checked" : function(c){
\r
761 var r = [], ri = -1;
\r
762 for(var i = 0, ci; ci = c[i]; i++){
\r
763 if(ci.checked == true){
\r
770 "not" : function(c, ss){
\r
771 return Ext.DomQuery.filter(c, ss, true);
\r
774 "any" : function(c, selectors){
\r
775 var ss = selectors.split('|'),
\r
776 r = [], ri = -1, s;
\r
777 for(var i = 0, ci; ci = c[i]; i++){
\r
778 for(var j = 0; s = ss[j]; j++){
\r
779 if(Ext.DomQuery.is(ci, s)){
\r
788 "odd" : function(c){
\r
789 return this["nth-child"](c, "odd");
\r
792 "even" : function(c){
\r
793 return this["nth-child"](c, "even");
\r
796 "nth" : function(c, a){
\r
797 return c[a-1] || [];
\r
800 "first" : function(c){
\r
804 "last" : function(c){
\r
805 return c[c.length-1] || [];
\r
808 "has" : function(c, ss){
\r
809 var s = Ext.DomQuery.select,
\r
811 for(var i = 0, ci; ci = c[i]; i++){
\r
812 if(s(ss, ci).length > 0){
\r
819 "next" : function(c, ss){
\r
820 var is = Ext.DomQuery.is,
\r
822 for(var i = 0, ci; ci = c[i]; i++){
\r
824 if(n && is(n, ss)){
\r
831 "prev" : function(c, ss){
\r
832 var is = Ext.DomQuery.is,
\r
834 for(var i = 0, ci; ci = c[i]; i++){
\r
836 if(n && is(n, ss)){
\r
846 <div id="method-Ext-query"></div>/**
\r
847 * Selects an array of DOM nodes by CSS/XPath selector. Shorthand of {@link Ext.DomQuery#select}
\r
848 * @param {String} path The selector/xpath query
\r
849 * @param {Node} root (optional) The start of the query (defaults to document).
\r
854 Ext.query = Ext.DomQuery.select;
\r