Upgrade to ExtJS 3.1.0 - Released 12/16/2009
[extjs.git] / src / core / core / DomQuery.js
index b22a07b..0286f57 100644 (file)
@@ -1,5 +1,5 @@
 /*!
- * Ext JS Library 3.0.0
+ * Ext JS Library 3.1.0
  * Copyright(c) 2006-2009 Ext JS, LLC
  * licensing@extjs.com
  * http://www.extjs.com/license
@@ -84,7 +84,6 @@ Ext.DomQuery = function(){
            // IE runs the same speed using setAttribute, however FF slows way down\r
            // and Safari completely fails so they need to continue to use expandos.\r
            isIE = window.ActiveXObject ? true : false,\r
-        isOpera = Ext.isOpera,\r
            key = 30803;\r
            \r
     // this eval is stop the compressor from\r
@@ -179,7 +178,7 @@ Ext.DomQuery = function(){
         }else if(mode == "/" || mode == ">"){\r
             var utag = tagName.toUpperCase();\r
             for(var i = 0, ni, cn; ni = ns[i]; i++){\r
-                cn = isOpera ? ni.childNodes : (ni.children || ni.childNodes);\r
+                cn = ni.childNodes;\r
                 for(var j = 0, cj; cj = cn[j]; j++){\r
                     if(cj.nodeName == utag || cj.nodeName == tagName  || tagName == '*'){\r
                         result[++ri] = cj;\r
@@ -359,7 +358,7 @@ Ext.DomQuery = function(){
         if(!len1){\r
             return c2;\r
         }\r
-        if(isIE && c1[0].selectSingleNode){\r
+        if(isIE && typeof c1[0].selectSingleNode != "undefined"){\r
             return quickDiffIEXml(c1, c2);\r
         }        \r
         for(var i = 0; i < len1; i++){\r
@@ -523,9 +522,11 @@ Ext.DomQuery = function(){
             if(!valueCache[path]){\r
                 valueCache[path] = Ext.DomQuery.compile(path, "select");\r
             }\r
-            var n = valueCache[path](root),\r
-               v;\r
+            var n = valueCache[path](root), v;\r
             n = n[0] ? n[0] : n;\r
+            \r
+            if (typeof n.normalize == 'function') n.normalize();\r
+            \r
             v = (n && n.firstChild ? n.firstChild.nodeValue : null);\r
             return ((v === null||v === undefined||v==='') ? defaultValue : v);\r
         },\r
@@ -628,8 +629,29 @@ Ext.DomQuery = function(){
         },\r
 \r
         /**\r
-         * Collection of "pseudo class" processors. Each processor is passed the current nodeset (array)\r
-         * and the argument (if any) supplied in the selector.\r
+         * <p>Object hash of "pseudo class" filter functions which are used when filtering selections. Each function is passed\r
+         * two parameters:</p><div class="mdetail-params"><ul>\r
+         * <li><b>c</b> : Array<div class="sub-desc">An Array of DOM elements to filter.</div></li>\r
+         * <li><b>v</b> : String<div class="sub-desc">The argument (if any) supplied in the selector.</div></li>\r
+         * </ul></div>\r
+         * <p>A filter function returns an Array of DOM elements which conform to the pseudo class.</p>\r
+         * <p>In addition to the provided pseudo classes listed above such as <code>first-child</code> and <code>nth-child</code>,\r
+         * developers may add additional, custom psuedo class filters to select elements according to application-specific requirements.</p>\r
+         * <p>For example, to filter <code>&lt;a></code> elements to only return links to <i>external</i> resources:</p>\r
+         * <code><pre>\r
+Ext.DomQuery.pseudos.external = function(c, v){\r
+    var r = [], ri = -1;\r
+    for(var i = 0, ci; ci = c[i]; i++){\r
+//      Include in result set only if it's a link to an external resource\r
+        if(ci.hostname != location.hostname){\r
+            r[++ri] = ci;\r
+        }\r
+    }\r
+    return r;\r
+};</pre></code>\r
+         * Then external links could be gathered with the following statement:<code><pre>\r
+var externalLinks = Ext.select("a:external");\r
+</code></pre>\r
          */\r
         pseudos : {\r
             "first-child" : function(c){\r