+
The source code
@@ -85,7 +86,6 @@ Ext.DomQuery = function(){
// IE runs the same speed using setAttribute, however FF slows way down
// and Safari completely fails so they need to continue to use expandos.
isIE = window.ActiveXObject ? true : false,
- isOpera = Ext.isOpera,
key = 30803;
// this eval is stop the compressor from
@@ -180,7 +180,7 @@ Ext.DomQuery = function(){
}else if(mode == "/" || mode == ">"){
var utag = tagName.toUpperCase();
for(var i = 0, ni, cn; ni = ns[i]; i++){
- cn = isOpera ? ni.childNodes : (ni.children || ni.childNodes);
+ cn = ni.childNodes;
for(var j = 0, cj; cj = cn[j]; j++){
if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
result[++ri] = cj;
@@ -360,7 +360,7 @@ Ext.DomQuery = function(){
if(!len1){
return c2;
}
- if(isIE && c1[0].selectSingleNode){
+ if(isIE && typeof c1[0].selectSingleNode != "undefined"){
return quickDiffIEXml(c1, c2);
}
for(var i = 0; i < len1; i++){
@@ -524,9 +524,11 @@ Ext.DomQuery = function(){
if(!valueCache[path]){
valueCache[path] = Ext.DomQuery.compile(path, "select");
}
- var n = valueCache[path](root),
- v;
+ var n = valueCache[path](root), v;
n = n[0] ? n[0] : n;
+
+ if (typeof n.normalize == 'function') n.normalize();
+
v = (n && n.firstChild ? n.firstChild.nodeValue : null);
return ((v === null||v === undefined||v==='') ? defaultValue : v);
},
@@ -629,8 +631,29 @@ Ext.DomQuery = function(){
},
/**
- * Collection of "pseudo class" processors. Each processor is passed the current nodeset (array)
- * and the argument (if any) supplied in the selector.
+ *
Object hash of "pseudo class" filter functions which are used when filtering selections. Each function is passed
+ * two parameters:
+ *
c : Array
An Array of DOM elements to filter.
+ *
v : String
The argument (if any) supplied in the selector.
+ *
+ *
A filter function returns an Array of DOM elements which conform to the pseudo class.
+ *
In addition to the provided pseudo classes listed above such as first-child and nth-child,
+ * developers may add additional, custom psuedo class filters to select elements according to application-specific requirements.
+ *
For example, to filter <a> elements to only return links to external resources:
+ *
+Ext.DomQuery.pseudos.external = function(c, v){
+ var r = [], ri = -1;
+ for(var i = 0, ci; ci = c[i]; i++){
+// Include in result set only if it's a link to an external resource
+ if(ci.hostname != location.hostname){
+ r[++ri] = ci;
+ }
+ }
+ return r;
+};
+ * Then external links could be gathered with the following statement: