3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
8 * This is code is also distributed under MIT license for use
\r
9 * with jQuery and prototype JavaScript libraries.
\r
12 * @class Ext.DomQuery
\r
13 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
15 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
18 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
20 <h4>Element Selectors:</h4>
\r
22 <li> <b>*</b> any element</li>
\r
23 <li> <b>E</b> an element with the tag E</li>
\r
24 <li> <b>E F</b> All descendent elements of E that have the tag F</li>
\r
25 <li> <b>E > F</b> or <b>E/F</b> all direct children elements of E that have the tag F</li>
\r
26 <li> <b>E + F</b> all elements with the tag F that are immediately preceded by an element with the tag E</li>
\r
27 <li> <b>E ~ F</b> all elements with the tag F that are preceded by a sibling element with the tag E</li>
\r
29 <h4>Attribute Selectors:</h4>
\r
30 <p>The use of @ and quotes are optional. For example, div[@foo='bar'] is also a valid attribute selector.</p>
\r
32 <li> <b>E[foo]</b> has an attribute "foo"</li>
\r
33 <li> <b>E[foo=bar]</b> has an attribute "foo" that equals "bar"</li>
\r
34 <li> <b>E[foo^=bar]</b> has an attribute "foo" that starts with "bar"</li>
\r
35 <li> <b>E[foo$=bar]</b> has an attribute "foo" that ends with "bar"</li>
\r
36 <li> <b>E[foo*=bar]</b> has an attribute "foo" that contains the substring "bar"</li>
\r
37 <li> <b>E[foo%=2]</b> has an attribute "foo" that is evenly divisible by 2</li>
\r
38 <li> <b>E[foo!=bar]</b> has an attribute "foo" that does not equal "bar"</li>
\r
40 <h4>Pseudo Classes:</h4>
\r
42 <li> <b>E:first-child</b> E is the first child of its parent</li>
\r
43 <li> <b>E:last-child</b> E is the last child of its parent</li>
\r
44 <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
45 <li> <b>E:nth-child(odd)</b> E is an odd child of its parent</li>
\r
46 <li> <b>E:nth-child(even)</b> E is an even child of its parent</li>
\r
47 <li> <b>E:only-child</b> E is the only child of its parent</li>
\r
48 <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
49 <li> <b>E:first</b> the first E in the resultset</li>
\r
50 <li> <b>E:last</b> the last E in the resultset</li>
\r
51 <li> <b>E:nth(<i>n</i>)</b> the <i>n</i>th E in the resultset (1 based)</li>
\r
52 <li> <b>E:odd</b> shortcut for :nth-child(odd)</li>
\r
53 <li> <b>E:even</b> shortcut for :nth-child(even)</li>
\r
54 <li> <b>E:contains(foo)</b> E's innerHTML contains the substring "foo"</li>
\r
55 <li> <b>E:nodeValue(foo)</b> E contains a textNode with a nodeValue that equals "foo"</li>
\r
56 <li> <b>E:not(S)</b> an E element that does not match simple selector S</li>
\r
57 <li> <b>E:has(S)</b> an E element that has a descendent that matches simple selector S</li>
\r
58 <li> <b>E:next(S)</b> an E element whose next sibling matches simple selector S</li>
\r
59 <li> <b>E:prev(S)</b> an E element whose previous sibling matches simple selector S</li>
\r
61 <h4>CSS Value Selectors:</h4>
\r
63 <li> <b>E{display=none}</b> css value "display" that equals "none"</li>
\r
64 <li> <b>E{display^=none}</b> css value "display" that starts with "none"</li>
\r
65 <li> <b>E{display$=none}</b> css value "display" that ends with "none"</li>
\r
66 <li> <b>E{display*=none}</b> css value "display" that contains the substring "none"</li>
\r
67 <li> <b>E{display%=2}</b> css value "display" that is evenly divisible by 2</li>
\r
68 <li> <b>E{display!=none}</b> css value "display" that does not equal "none"</li>
\r
72 Ext.DomQuery = function(){
\r
77 trimRe = /^\s+|\s+$/g,
\r
78 tplRe = /\{(\d+)\}/g,
\r
79 modeRe = /^(\s?[\/>+~]\s?|\s|$)/,
\r
80 tagTokenRe = /^(#)?([\w-\*]+)/,
\r
81 nthRe = /(\d*)n\+?(\d*)/,
\r
83 // This is for IE MSXML which does not support expandos.
\r
84 // IE runs the same speed using setAttribute, however FF slows way down
\r
85 // and Safari completely fails so they need to continue to use expandos.
\r
86 isIE = window.ActiveXObject ? true : false,
\r
89 // this eval is stop the compressor from
\r
90 // renaming the variable to something shorter
\r
91 eval("var batch = 30803;");
\r
93 function child(p, index){
\r
97 if(n.nodeType == 1){
\r
108 while((n = n.nextSibling) && n.nodeType != 1);
\r
113 while((n = n.previousSibling) && n.nodeType != 1);
\r
117 function children(d){
\r
118 var n = d.firstChild, ni = -1,
\r
121 nx = n.nextSibling;
\r
122 if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
\r
125 n.nodeIndex = ++ni;
\r
132 function byClassName(c, a, v){
\r
136 var r = [], ri = -1, cn;
\r
137 for(var i = 0, ci; ci = c[i]; i++){
\r
138 if((' '+ci.className+' ').indexOf(v) != -1){
\r
145 function attrValue(n, attr){
\r
146 if(!n.tagName && typeof n.length != "undefined"){
\r
155 if(attr == "class" || attr == "className"){
\r
156 return n.className;
\r
158 return n.getAttribute(attr) || n[attr];
\r
162 function getNodes(ns, mode, tagName){
\r
163 var result = [], ri = -1, cs;
\r
167 tagName = tagName || "*";
\r
168 if(typeof ns.getElementsByTagName != "undefined"){
\r
172 for(var i = 0, ni; ni = ns[i]; i++){
\r
173 cs = ni.getElementsByTagName(tagName);
\r
174 for(var j = 0, ci; ci = cs[j]; j++){
\r
178 }else if(mode == "/" || mode == ">"){
\r
179 var utag = tagName.toUpperCase();
\r
180 for(var i = 0, ni, cn; ni = ns[i]; i++){
\r
181 cn = ni.childNodes;
\r
182 for(var j = 0, cj; cj = cn[j]; j++){
\r
183 if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
\r
188 }else if(mode == "+"){
\r
189 var utag = tagName.toUpperCase();
\r
190 for(var i = 0, n; n = ns[i]; i++){
\r
191 while((n = n.nextSibling) && n.nodeType != 1);
\r
192 if(n && (n.nodeName == utag || n.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)){
\r
200 if (n.nodeName == utag || n.nodeName == tagName || tagName == '*'){
\r
209 function concat(a, b){
\r
211 return a.concat(b);
\r
213 for(var i = 0, l = b.length; i < l; i++){
\r
214 a[a.length] = b[i];
\r
219 function byTag(cs, tagName){
\r
220 if(cs.tagName || cs == document){
\r
226 var r = [], ri = -1;
\r
227 tagName = tagName.toLowerCase();
\r
228 for(var i = 0, ci; ci = cs[i]; i++){
\r
229 if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){
\r
236 function byId(cs, attr, id){
\r
237 if(cs.tagName || cs == document){
\r
243 var r = [], ri = -1;
\r
244 for(var i = 0,ci; ci = cs[i]; i++){
\r
245 if(ci && ci.id == id){
\r
253 function byAttribute(cs, attr, value, op, custom){
\r
257 f = Ext.DomQuery.operators[op];
\r
258 for(var i = 0, ci; ci = cs[i]; i++){
\r
259 if(ci.nodeType != 1){
\r
264 a = Ext.DomQuery.getStyle(ci, attr);
\r
266 else if(attr == "class" || attr == "className"){
\r
268 }else if(attr == "for"){
\r
270 }else if(attr == "href"){
\r
271 a = ci.getAttribute("href", 2);
\r
273 a = ci.getAttribute(attr);
\r
275 if((f && f(a, value)) || (!f && a)){
\r
282 function byPseudo(cs, name, value){
\r
283 return Ext.DomQuery.pseudos[name](cs, value);
\r
286 function nodupIEXml(cs){
\r
289 cs[0].setAttribute("_nodup", d);
\r
291 for(var i = 1, len = cs.length; i < len; i++){
\r
293 if(!c.getAttribute("_nodup") != d){
\r
294 c.setAttribute("_nodup", d);
\r
298 for(var i = 0, len = cs.length; i < len; i++){
\r
299 cs[i].removeAttribute("_nodup");
\r
304 function nodup(cs){
\r
308 var len = cs.length, c, i, r = cs, cj, ri = -1;
\r
309 if(!len || typeof cs.nodeType != "undefined" || len == 1){
\r
312 if(isIE && typeof cs[0].selectSingleNode != "undefined"){
\r
313 return nodupIEXml(cs);
\r
317 for(i = 1; c = cs[i]; i++){
\r
322 for(var j = 0; j < i; j++){
\r
325 for(j = i+1; cj = cs[j]; j++){
\r
326 if(cj._nodup != d){
\r
337 function quickDiffIEXml(c1, c2){
\r
340 for(var i = 0, len = c1.length; i < len; i++){
\r
341 c1[i].setAttribute("_qdiff", d);
\r
343 for(var i = 0, len = c2.length; i < len; i++){
\r
344 if(c2[i].getAttribute("_qdiff") != d){
\r
345 r[r.length] = c2[i];
\r
348 for(var i = 0, len = c1.length; i < len; i++){
\r
349 c1[i].removeAttribute("_qdiff");
\r
354 function quickDiff(c1, c2){
\r
355 var len1 = c1.length,
\r
361 if(isIE && typeof c1[0].selectSingleNode != "undefined"){
\r
362 return quickDiffIEXml(c1, c2);
\r
364 for(var i = 0; i < len1; i++){
\r
367 for(var i = 0, len = c2.length; i < len; i++){
\r
368 if(c2[i]._qdiff != d){
\r
369 r[r.length] = c2[i];
\r
375 function quickId(ns, mode, root, id){
\r
377 var d = root.ownerDocument || root;
\r
378 return d.getElementById(id);
\r
380 ns = getNodes(ns, mode, "*");
\r
381 return byId(ns, null, id);
\r
385 getStyle : function(el, name){
\r
386 return Ext.fly(el).getStyle(name);
\r
389 * Compiles a selector/xpath query into a reusable function. The returned function
\r
390 * takes one parameter "root" (optional), which is the context node from where the query should start.
\r
391 * @param {String} selector The selector/xpath query
\r
392 * @param {String} type (optional) Either "select" (the default) or "simple" for a simple selector match
\r
393 * @return {Function}
\r
395 compile : function(path, type){
\r
396 type = type || "select";
\r
398 var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"],
\r
399 q = path, mode, lq,
\r
400 tk = Ext.DomQuery.matchers,
\r
403 // accept leading mode switch
\r
404 lmode = q.match(modeRe);
\r
406 if(lmode && lmode[1]){
\r
407 fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";';
\r
408 q = q.replace(lmode[1], "");
\r
410 // strip leading slashes
\r
411 while(path.substr(0, 1)=="/"){
\r
412 path = path.substr(1);
\r
415 while(q && lq != q){
\r
417 var tm = q.match(tagTokenRe);
\r
418 if(type == "select"){
\r
421 fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
\r
423 fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
\r
425 q = q.replace(tm[0], "");
\r
426 }else if(q.substr(0, 1) != '@'){
\r
427 fn[fn.length] = 'n = getNodes(n, mode, "*");';
\r
432 fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
\r
434 fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
\r
436 q = q.replace(tm[0], "");
\r
439 while(!(mm = q.match(modeRe))){
\r
440 var matched = false;
\r
441 for(var j = 0; j < tklen; j++){
\r
443 var m = q.match(t.re);
\r
445 fn[fn.length] = t.select.replace(tplRe, function(x, i){
\r
448 q = q.replace(m[0], "");
\r
453 // prevent infinite loop on bad selector
\r
455 throw 'Error parsing selector, parsing failed at "' + q + '"';
\r
459 fn[fn.length] = 'mode="'+mm[1].replace(trimRe, "")+'";';
\r
460 q = q.replace(mm[1], "");
\r
463 fn[fn.length] = "return nodup(n);\n}";
\r
469 * Selects a group of elements.
\r
470 * @param {String} selector The selector/xpath query (can be a comma separated list of selectors)
\r
471 * @param {Node} root (optional) The start of the query (defaults to document).
\r
472 * @return {Array} An Array of DOM elements which match the selector. If there are
\r
473 * no matches, and empty Array is returned.
\r
475 select : function(path, root, type){
\r
476 if(!root || root == document){
\r
479 if(typeof root == "string"){
\r
480 root = document.getElementById(root);
\r
482 var paths = path.split(","),
\r
484 for(var i = 0, len = paths.length; i < len; i++){
\r
485 var p = paths[i].replace(trimRe, "");
\r
487 cache[p] = Ext.DomQuery.compile(p);
\r
489 throw p + " is not a valid selector";
\r
492 var result = cache[p](root);
\r
493 if(result && result != document){
\r
494 results = results.concat(result);
\r
497 if(paths.length > 1){
\r
498 return nodup(results);
\r
504 * Selects a single element.
\r
505 * @param {String} selector The selector/xpath query
\r
506 * @param {Node} root (optional) The start of the query (defaults to document).
\r
507 * @return {Element} The DOM element which matched the selector.
\r
509 selectNode : function(path, root){
\r
510 return Ext.DomQuery.select(path, root)[0];
\r
514 * Selects the value of a node, optionally replacing null with the defaultValue.
\r
515 * @param {String} selector The selector/xpath query
\r
516 * @param {Node} root (optional) The start of the query (defaults to document).
\r
517 * @param {String} defaultValue
\r
520 selectValue : function(path, root, defaultValue){
\r
521 path = path.replace(trimRe, "");
\r
522 if(!valueCache[path]){
\r
523 valueCache[path] = Ext.DomQuery.compile(path, "select");
\r
525 var n = valueCache[path](root), v;
\r
526 n = n[0] ? n[0] : n;
\r
528 if (typeof n.normalize == 'function') n.normalize();
\r
530 v = (n && n.firstChild ? n.firstChild.nodeValue : null);
\r
531 return ((v === null||v === undefined||v==='') ? defaultValue : v);
\r
535 * Selects the value of a node, parsing integers and floats. Returns the defaultValue, or 0 if none is specified.
\r
536 * @param {String} selector The selector/xpath query
\r
537 * @param {Node} root (optional) The start of the query (defaults to document).
\r
538 * @param {Number} defaultValue
\r
541 selectNumber : function(path, root, defaultValue){
\r
542 var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
\r
543 return parseFloat(v);
\r
547 * Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child)
\r
548 * @param {String/HTMLElement/Array} el An element id, element or array of elements
\r
549 * @param {String} selector The simple selector to test
\r
550 * @return {Boolean}
\r
552 is : function(el, ss){
\r
553 if(typeof el == "string"){
\r
554 el = document.getElementById(el);
\r
556 var isArray = Ext.isArray(el),
\r
557 result = Ext.DomQuery.filter(isArray ? el : [el], ss);
\r
558 return isArray ? (result.length == el.length) : (result.length > 0);
\r
562 * Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child)
\r
563 * @param {Array} el An array of elements to filter
\r
564 * @param {String} selector The simple selector to test
\r
565 * @param {Boolean} nonMatches If true, it returns the elements that DON'T match
\r
566 * the selector instead of the ones that match
\r
567 * @return {Array} An Array of DOM elements which match the selector. If there are
\r
568 * no matches, and empty Array is returned.
\r
570 filter : function(els, ss, nonMatches){
\r
571 ss = ss.replace(trimRe, "");
\r
572 if(!simpleCache[ss]){
\r
573 simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
\r
575 var result = simpleCache[ss](els);
\r
576 return nonMatches ? quickDiff(result, els) : result;
\r
580 * Collection of matching regular expressions and code snippets.
\r
584 select: 'n = byClassName(n, null, " {1} ");'
\r
586 re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
\r
587 select: 'n = byPseudo(n, "{1}", "{2}");'
\r
589 re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
\r
590 select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
\r
593 select: 'n = byId(n, null, "{1}");'
\r
596 select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
\r
601 * Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
\r
602 * 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
605 "=" : function(a, v){
\r
608 "!=" : function(a, v){
\r
611 "^=" : function(a, v){
\r
612 return a && a.substr(0, v.length) == v;
\r
614 "$=" : function(a, v){
\r
615 return a && a.substr(a.length-v.length) == v;
\r
617 "*=" : function(a, v){
\r
618 return a && a.indexOf(v) !== -1;
\r
620 "%=" : function(a, v){
\r
621 return (a % v) == 0;
\r
623 "|=" : function(a, v){
\r
624 return a && (a == v || a.substr(0, v.length+1) == v+'-');
\r
626 "~=" : function(a, v){
\r
627 return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
\r
632 * <p>Object hash of "pseudo class" filter functions which are used when filtering selections. Each function is passed
\r
633 * two parameters:</p><div class="mdetail-params"><ul>
\r
634 * <li><b>c</b> : Array<div class="sub-desc">An Array of DOM elements to filter.</div></li>
\r
635 * <li><b>v</b> : String<div class="sub-desc">The argument (if any) supplied in the selector.</div></li>
\r
637 * <p>A filter function returns an Array of DOM elements which conform to the pseudo class.</p>
\r
638 * <p>In addition to the provided pseudo classes listed above such as <code>first-child</code> and <code>nth-child</code>,
\r
639 * developers may add additional, custom psuedo class filters to select elements according to application-specific requirements.</p>
\r
640 * <p>For example, to filter <code><a></code> elements to only return links to <i>external</i> resources:</p>
\r
642 Ext.DomQuery.pseudos.external = function(c, v){
\r
643 var r = [], ri = -1;
\r
644 for(var i = 0, ci; ci = c[i]; i++){
\r
645 // Include in result set only if it's a link to an external resource
\r
646 if(ci.hostname != location.hostname){
\r
652 * Then external links could be gathered with the following statement:<code><pre>
\r
653 var externalLinks = Ext.select("a:external");
\r
657 "first-child" : function(c){
\r
658 var r = [], ri = -1, n;
\r
659 for(var i = 0, ci; ci = n = c[i]; i++){
\r
660 while((n = n.previousSibling) && n.nodeType != 1);
\r
668 "last-child" : function(c){
\r
669 var r = [], ri = -1, n;
\r
670 for(var i = 0, ci; ci = n = c[i]; i++){
\r
671 while((n = n.nextSibling) && n.nodeType != 1);
\r
679 "nth-child" : function(c, a) {
\r
680 var r = [], ri = -1,
\r
681 m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a),
\r
682 f = (m[1] || 1) - 0, l = m[2] - 0;
\r
683 for(var i = 0, n; n = c[i]; i++){
\r
684 var pn = n.parentNode;
\r
685 if (batch != pn._batch) {
\r
687 for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
\r
688 if(cn.nodeType == 1){
\r
689 cn.nodeIndex = ++j;
\r
695 if (l == 0 || n.nodeIndex == l){
\r
698 } else if ((n.nodeIndex + l) % f == 0){
\r
706 "only-child" : function(c){
\r
707 var r = [], ri = -1;;
\r
708 for(var i = 0, ci; ci = c[i]; i++){
\r
709 if(!prev(ci) && !next(ci)){
\r
716 "empty" : function(c){
\r
717 var r = [], ri = -1;
\r
718 for(var i = 0, ci; ci = c[i]; i++){
\r
719 var cns = ci.childNodes, j = 0, cn, empty = true;
\r
720 while(cn = cns[j]){
\r
722 if(cn.nodeType == 1 || cn.nodeType == 3){
\r
734 "contains" : function(c, v){
\r
735 var r = [], ri = -1;
\r
736 for(var i = 0, ci; ci = c[i]; i++){
\r
737 if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
\r
744 "nodeValue" : function(c, v){
\r
745 var r = [], ri = -1;
\r
746 for(var i = 0, ci; ci = c[i]; i++){
\r
747 if(ci.firstChild && ci.firstChild.nodeValue == v){
\r
754 "checked" : function(c){
\r
755 var r = [], ri = -1;
\r
756 for(var i = 0, ci; ci = c[i]; i++){
\r
757 if(ci.checked == true){
\r
764 "not" : function(c, ss){
\r
765 return Ext.DomQuery.filter(c, ss, true);
\r
768 "any" : function(c, selectors){
\r
769 var ss = selectors.split('|'),
\r
770 r = [], ri = -1, s;
\r
771 for(var i = 0, ci; ci = c[i]; i++){
\r
772 for(var j = 0; s = ss[j]; j++){
\r
773 if(Ext.DomQuery.is(ci, s)){
\r
782 "odd" : function(c){
\r
783 return this["nth-child"](c, "odd");
\r
786 "even" : function(c){
\r
787 return this["nth-child"](c, "even");
\r
790 "nth" : function(c, a){
\r
791 return c[a-1] || [];
\r
794 "first" : function(c){
\r
798 "last" : function(c){
\r
799 return c[c.length-1] || [];
\r
802 "has" : function(c, ss){
\r
803 var s = Ext.DomQuery.select,
\r
805 for(var i = 0, ci; ci = c[i]; i++){
\r
806 if(s(ss, ci).length > 0){
\r
813 "next" : function(c, ss){
\r
814 var is = Ext.DomQuery.is,
\r
816 for(var i = 0, ci; ci = c[i]; i++){
\r
818 if(n && is(n, ss)){
\r
825 "prev" : function(c, ss){
\r
826 var is = Ext.DomQuery.is,
\r
828 for(var i = 0, ci; ci = c[i]; i++){
\r
830 if(n && is(n, ss)){
\r
841 * Selects an array of DOM nodes by CSS/XPath selector. Shorthand of {@link Ext.DomQuery#select}
\r
842 * @param {String} path The selector/xpath query
\r
843 * @param {Node} root (optional) The start of the query (defaults to document).
\r
848 Ext.query = Ext.DomQuery.select;
\r