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
87 isOpera = Ext.isOpera,
\r
90 // this eval is stop the compressor from
\r
91 // renaming the variable to something shorter
\r
92 eval("var batch = 30803;");
\r
94 function child(p, index){
\r
98 if(n.nodeType == 1){
\r
109 while((n = n.nextSibling) && n.nodeType != 1);
\r
114 while((n = n.previousSibling) && n.nodeType != 1);
\r
118 function children(d){
\r
119 var n = d.firstChild, ni = -1,
\r
122 nx = n.nextSibling;
\r
123 if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
\r
126 n.nodeIndex = ++ni;
\r
133 function byClassName(c, a, v){
\r
137 var r = [], ri = -1, cn;
\r
138 for(var i = 0, ci; ci = c[i]; i++){
\r
139 if((' '+ci.className+' ').indexOf(v) != -1){
\r
146 function attrValue(n, attr){
\r
147 if(!n.tagName && typeof n.length != "undefined"){
\r
156 if(attr == "class" || attr == "className"){
\r
157 return n.className;
\r
159 return n.getAttribute(attr) || n[attr];
\r
163 function getNodes(ns, mode, tagName){
\r
164 var result = [], ri = -1, cs;
\r
168 tagName = tagName || "*";
\r
169 if(typeof ns.getElementsByTagName != "undefined"){
\r
173 for(var i = 0, ni; ni = ns[i]; i++){
\r
174 cs = ni.getElementsByTagName(tagName);
\r
175 for(var j = 0, ci; ci = cs[j]; j++){
\r
179 }else if(mode == "/" || mode == ">"){
\r
180 var utag = tagName.toUpperCase();
\r
181 for(var i = 0, ni, cn; ni = ns[i]; i++){
\r
182 cn = isOpera ? ni.childNodes : (ni.children || ni.childNodes);
\r
183 for(var j = 0, cj; cj = cn[j]; j++){
\r
184 if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
\r
189 }else if(mode == "+"){
\r
190 var utag = tagName.toUpperCase();
\r
191 for(var i = 0, n; n = ns[i]; i++){
\r
192 while((n = n.nextSibling) && n.nodeType != 1);
\r
193 if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){
\r
197 }else if(mode == "~"){
\r
198 var utag = tagName.toUpperCase();
\r
199 for(var i = 0, n; n = ns[i]; i++){
\r
200 while((n = n.nextSibling)){
\r
201 if (n.nodeName == utag || n.nodeName == tagName || tagName == '*'){
\r
210 function concat(a, b){
\r
212 return a.concat(b);
\r
214 for(var i = 0, l = b.length; i < l; i++){
\r
215 a[a.length] = b[i];
\r
220 function byTag(cs, tagName){
\r
221 if(cs.tagName || cs == document){
\r
227 var r = [], ri = -1;
\r
228 tagName = tagName.toLowerCase();
\r
229 for(var i = 0, ci; ci = cs[i]; i++){
\r
230 if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){
\r
237 function byId(cs, attr, id){
\r
238 if(cs.tagName || cs == document){
\r
244 var r = [], ri = -1;
\r
245 for(var i = 0,ci; ci = cs[i]; i++){
\r
246 if(ci && ci.id == id){
\r
254 function byAttribute(cs, attr, value, op, custom){
\r
258 f = Ext.DomQuery.operators[op];
\r
259 for(var i = 0, ci; ci = cs[i]; i++){
\r
260 if(ci.nodeType != 1){
\r
265 a = Ext.DomQuery.getStyle(ci, attr);
\r
267 else if(attr == "class" || attr == "className"){
\r
269 }else if(attr == "for"){
\r
271 }else if(attr == "href"){
\r
272 a = ci.getAttribute("href", 2);
\r
274 a = ci.getAttribute(attr);
\r
276 if((f && f(a, value)) || (!f && a)){
\r
283 function byPseudo(cs, name, value){
\r
284 return Ext.DomQuery.pseudos[name](cs, value);
\r
287 function nodupIEXml(cs){
\r
290 cs[0].setAttribute("_nodup", d);
\r
292 for(var i = 1, len = cs.length; i < len; i++){
\r
294 if(!c.getAttribute("_nodup") != d){
\r
295 c.setAttribute("_nodup", d);
\r
299 for(var i = 0, len = cs.length; i < len; i++){
\r
300 cs[i].removeAttribute("_nodup");
\r
305 function nodup(cs){
\r
309 var len = cs.length, c, i, r = cs, cj, ri = -1;
\r
310 if(!len || typeof cs.nodeType != "undefined" || len == 1){
\r
313 if(isIE && typeof cs[0].selectSingleNode != "undefined"){
\r
314 return nodupIEXml(cs);
\r
318 for(i = 1; c = cs[i]; i++){
\r
323 for(var j = 0; j < i; j++){
\r
326 for(j = i+1; cj = cs[j]; j++){
\r
327 if(cj._nodup != d){
\r
338 function quickDiffIEXml(c1, c2){
\r
341 for(var i = 0, len = c1.length; i < len; i++){
\r
342 c1[i].setAttribute("_qdiff", d);
\r
344 for(var i = 0, len = c2.length; i < len; i++){
\r
345 if(c2[i].getAttribute("_qdiff") != d){
\r
346 r[r.length] = c2[i];
\r
349 for(var i = 0, len = c1.length; i < len; i++){
\r
350 c1[i].removeAttribute("_qdiff");
\r
355 function quickDiff(c1, c2){
\r
356 var len1 = c1.length,
\r
362 if(isIE && c1[0].selectSingleNode){
\r
363 return quickDiffIEXml(c1, c2);
\r
365 for(var i = 0; i < len1; i++){
\r
368 for(var i = 0, len = c2.length; i < len; i++){
\r
369 if(c2[i]._qdiff != d){
\r
370 r[r.length] = c2[i];
\r
376 function quickId(ns, mode, root, id){
\r
378 var d = root.ownerDocument || root;
\r
379 return d.getElementById(id);
\r
381 ns = getNodes(ns, mode, "*");
\r
382 return byId(ns, null, id);
\r
386 getStyle : function(el, name){
\r
387 return Ext.fly(el).getStyle(name);
\r
390 * Compiles a selector/xpath query into a reusable function. The returned function
\r
391 * takes one parameter "root" (optional), which is the context node from where the query should start.
\r
392 * @param {String} selector The selector/xpath query
\r
393 * @param {String} type (optional) Either "select" (the default) or "simple" for a simple selector match
\r
394 * @return {Function}
\r
396 compile : function(path, type){
\r
397 type = type || "select";
\r
399 var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"],
\r
400 q = path, mode, lq,
\r
401 tk = Ext.DomQuery.matchers,
\r
404 // accept leading mode switch
\r
405 lmode = q.match(modeRe);
\r
407 if(lmode && lmode[1]){
\r
408 fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";';
\r
409 q = q.replace(lmode[1], "");
\r
411 // strip leading slashes
\r
412 while(path.substr(0, 1)=="/"){
\r
413 path = path.substr(1);
\r
416 while(q && lq != q){
\r
418 var tm = q.match(tagTokenRe);
\r
419 if(type == "select"){
\r
422 fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
\r
424 fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
\r
426 q = q.replace(tm[0], "");
\r
427 }else if(q.substr(0, 1) != '@'){
\r
428 fn[fn.length] = 'n = getNodes(n, mode, "*");';
\r
433 fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
\r
435 fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
\r
437 q = q.replace(tm[0], "");
\r
440 while(!(mm = q.match(modeRe))){
\r
441 var matched = false;
\r
442 for(var j = 0; j < tklen; j++){
\r
444 var m = q.match(t.re);
\r
446 fn[fn.length] = t.select.replace(tplRe, function(x, i){
\r
449 q = q.replace(m[0], "");
\r
454 // prevent infinite loop on bad selector
\r
456 throw 'Error parsing selector, parsing failed at "' + q + '"';
\r
460 fn[fn.length] = 'mode="'+mm[1].replace(trimRe, "")+'";';
\r
461 q = q.replace(mm[1], "");
\r
464 fn[fn.length] = "return nodup(n);\n}";
\r
470 * Selects a group of elements.
\r
471 * @param {String} selector The selector/xpath query (can be a comma separated list of selectors)
\r
472 * @param {Node} root (optional) The start of the query (defaults to document).
\r
473 * @return {Array} An Array of DOM elements which match the selector. If there are
\r
474 * no matches, and empty Array is returned.
\r
476 select : function(path, root, type){
\r
477 if(!root || root == document){
\r
480 if(typeof root == "string"){
\r
481 root = document.getElementById(root);
\r
483 var paths = path.split(","),
\r
485 for(var i = 0, len = paths.length; i < len; i++){
\r
486 var p = paths[i].replace(trimRe, "");
\r
488 cache[p] = Ext.DomQuery.compile(p);
\r
490 throw p + " is not a valid selector";
\r
493 var result = cache[p](root);
\r
494 if(result && result != document){
\r
495 results = results.concat(result);
\r
498 if(paths.length > 1){
\r
499 return nodup(results);
\r
505 * Selects a single element.
\r
506 * @param {String} selector The selector/xpath query
\r
507 * @param {Node} root (optional) The start of the query (defaults to document).
\r
508 * @return {Element} The DOM element which matched the selector.
\r
510 selectNode : function(path, root){
\r
511 return Ext.DomQuery.select(path, root)[0];
\r
515 * Selects the value of a node, optionally replacing null with the defaultValue.
\r
516 * @param {String} selector The selector/xpath query
\r
517 * @param {Node} root (optional) The start of the query (defaults to document).
\r
518 * @param {String} defaultValue
\r
521 selectValue : function(path, root, defaultValue){
\r
522 path = path.replace(trimRe, "");
\r
523 if(!valueCache[path]){
\r
524 valueCache[path] = Ext.DomQuery.compile(path, "select");
\r
526 var n = valueCache[path](root),
\r
528 n = n[0] ? n[0] : n;
\r
529 v = (n && n.firstChild ? n.firstChild.nodeValue : null);
\r
530 return ((v === null||v === undefined||v==='') ? defaultValue : v);
\r
534 * Selects the value of a node, parsing integers and floats. Returns the defaultValue, or 0 if none is specified.
\r
535 * @param {String} selector The selector/xpath query
\r
536 * @param {Node} root (optional) The start of the query (defaults to document).
\r
537 * @param {Number} defaultValue
\r
540 selectNumber : function(path, root, defaultValue){
\r
541 var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
\r
542 return parseFloat(v);
\r
546 * Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child)
\r
547 * @param {String/HTMLElement/Array} el An element id, element or array of elements
\r
548 * @param {String} selector The simple selector to test
\r
549 * @return {Boolean}
\r
551 is : function(el, ss){
\r
552 if(typeof el == "string"){
\r
553 el = document.getElementById(el);
\r
555 var isArray = Ext.isArray(el),
\r
556 result = Ext.DomQuery.filter(isArray ? el : [el], ss);
\r
557 return isArray ? (result.length == el.length) : (result.length > 0);
\r
561 * Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child)
\r
562 * @param {Array} el An array of elements to filter
\r
563 * @param {String} selector The simple selector to test
\r
564 * @param {Boolean} nonMatches If true, it returns the elements that DON'T match
\r
565 * the selector instead of the ones that match
\r
566 * @return {Array} An Array of DOM elements which match the selector. If there are
\r
567 * no matches, and empty Array is returned.
\r
569 filter : function(els, ss, nonMatches){
\r
570 ss = ss.replace(trimRe, "");
\r
571 if(!simpleCache[ss]){
\r
572 simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
\r
574 var result = simpleCache[ss](els);
\r
575 return nonMatches ? quickDiff(result, els) : result;
\r
579 * Collection of matching regular expressions and code snippets.
\r
583 select: 'n = byClassName(n, null, " {1} ");'
\r
585 re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
\r
586 select: 'n = byPseudo(n, "{1}", "{2}");'
\r
588 re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
\r
589 select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
\r
592 select: 'n = byId(n, null, "{1}");'
\r
595 select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
\r
600 * Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
\r
601 * 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
604 "=" : function(a, v){
\r
607 "!=" : function(a, v){
\r
610 "^=" : function(a, v){
\r
611 return a && a.substr(0, v.length) == v;
\r
613 "$=" : function(a, v){
\r
614 return a && a.substr(a.length-v.length) == v;
\r
616 "*=" : function(a, v){
\r
617 return a && a.indexOf(v) !== -1;
\r
619 "%=" : function(a, v){
\r
620 return (a % v) == 0;
\r
622 "|=" : function(a, v){
\r
623 return a && (a == v || a.substr(0, v.length+1) == v+'-');
\r
625 "~=" : function(a, v){
\r
626 return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
\r
631 * <p>Object hash of "pseudo class" filter functions which are used when filtering selections. Each function is passed
\r
632 * two parameters:</p><div class="mdetail-params"><ul>
\r
633 * <li><b>c</b> : Array<div class="sub-desc">An Array of DOM elements to filter.</div></li>
\r
634 * <li><b>v</b> : String<div class="sub-desc">The argument (if any) supplied in the selector.</div></li>
\r
636 * <p>A filter function returns an Array of DOM elements which conform to the pseudo class.</p>
\r
637 * <p>In addition to the provided pseudo classes listed above such as <code>first-child</code> and <code>nth-child</code>,
\r
638 * developers may add additional, custom psuedo class filters to select elements according to application-specific requirements.</p>
\r
639 * <p>For example, to filter <code><a></code> elements to only return links to <i>external</i> resources:</p>
\r
641 Ext.DomQuery.pseudos.external = function(c, v){
\r
642 var r = [], ri = -1;
\r
643 for(var i = 0, ci; ci = c[i]; i++){
\r
644 // Include in result set only if it's a link to an external resource
\r
645 if(ci.hostname != location.hostname){
\r
651 * Then external links could be gathered with the following statement:<code><pre>
\r
652 var externalLinks = Ext.select("a:external");
\r
656 "first-child" : function(c){
\r
657 var r = [], ri = -1, n;
\r
658 for(var i = 0, ci; ci = n = c[i]; i++){
\r
659 while((n = n.previousSibling) && n.nodeType != 1);
\r
667 "last-child" : function(c){
\r
668 var r = [], ri = -1, n;
\r
669 for(var i = 0, ci; ci = n = c[i]; i++){
\r
670 while((n = n.nextSibling) && n.nodeType != 1);
\r
678 "nth-child" : function(c, a) {
\r
679 var r = [], ri = -1,
\r
680 m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a),
\r
681 f = (m[1] || 1) - 0, l = m[2] - 0;
\r
682 for(var i = 0, n; n = c[i]; i++){
\r
683 var pn = n.parentNode;
\r
684 if (batch != pn._batch) {
\r
686 for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
\r
687 if(cn.nodeType == 1){
\r
688 cn.nodeIndex = ++j;
\r
694 if (l == 0 || n.nodeIndex == l){
\r
697 } else if ((n.nodeIndex + l) % f == 0){
\r
705 "only-child" : function(c){
\r
706 var r = [], ri = -1;;
\r
707 for(var i = 0, ci; ci = c[i]; i++){
\r
708 if(!prev(ci) && !next(ci)){
\r
715 "empty" : function(c){
\r
716 var r = [], ri = -1;
\r
717 for(var i = 0, ci; ci = c[i]; i++){
\r
718 var cns = ci.childNodes, j = 0, cn, empty = true;
\r
719 while(cn = cns[j]){
\r
721 if(cn.nodeType == 1 || cn.nodeType == 3){
\r
733 "contains" : function(c, v){
\r
734 var r = [], ri = -1;
\r
735 for(var i = 0, ci; ci = c[i]; i++){
\r
736 if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
\r
743 "nodeValue" : function(c, v){
\r
744 var r = [], ri = -1;
\r
745 for(var i = 0, ci; ci = c[i]; i++){
\r
746 if(ci.firstChild && ci.firstChild.nodeValue == v){
\r
753 "checked" : function(c){
\r
754 var r = [], ri = -1;
\r
755 for(var i = 0, ci; ci = c[i]; i++){
\r
756 if(ci.checked == true){
\r
763 "not" : function(c, ss){
\r
764 return Ext.DomQuery.filter(c, ss, true);
\r
767 "any" : function(c, selectors){
\r
768 var ss = selectors.split('|'),
\r
769 r = [], ri = -1, s;
\r
770 for(var i = 0, ci; ci = c[i]; i++){
\r
771 for(var j = 0; s = ss[j]; j++){
\r
772 if(Ext.DomQuery.is(ci, s)){
\r
781 "odd" : function(c){
\r
782 return this["nth-child"](c, "odd");
\r
785 "even" : function(c){
\r
786 return this["nth-child"](c, "even");
\r
789 "nth" : function(c, a){
\r
790 return c[a-1] || [];
\r
793 "first" : function(c){
\r
797 "last" : function(c){
\r
798 return c[c.length-1] || [];
\r
801 "has" : function(c, ss){
\r
802 var s = Ext.DomQuery.select,
\r
804 for(var i = 0, ci; ci = c[i]; i++){
\r
805 if(s(ss, ci).length > 0){
\r
812 "next" : function(c, ss){
\r
813 var is = Ext.DomQuery.is,
\r
815 for(var i = 0, ci; ci = c[i]; i++){
\r
817 if(n && is(n, ss)){
\r
824 "prev" : function(c, ss){
\r
825 var is = Ext.DomQuery.is,
\r
827 for(var i = 0, ci; ci = c[i]; i++){
\r
829 if(n && is(n, ss)){
\r
840 * Selects an array of DOM nodes by CSS/XPath selector. Shorthand of {@link Ext.DomQuery#select}
\r
841 * @param {String} path The selector/xpath query
\r
842 * @param {Node} root (optional) The start of the query (defaults to document).
\r
847 Ext.query = Ext.DomQuery.select;
\r