[KSS-checkins] r41902 - kukit/kukit.js/branch/fschulze-js-compression/kukit

fschulze at codespeak.net fschulze at codespeak.net
Thu Apr 5 12:47:25 CEST 2007


Author: fschulze
Date: Thu Apr  5 12:47:24 2007
New Revision: 41902

Modified:
   kukit/kukit.js/branch/fschulze-js-compression/kukit/dom.js
Log:
Filter results of cssQuery to newly inserted nodes. Doesn't seem to help much though.

Modified: kukit/kukit.js/branch/fschulze-js-compression/kukit/dom.js
==============================================================================
--- kukit/kukit.js/branch/fschulze-js-compression/kukit/dom.js	(original)
+++ kukit/kukit.js/branch/fschulze-js-compression/kukit/dom.js	Thu Apr  5 12:47:24 2007
@@ -123,17 +123,40 @@
 *  really the query should start from the document root, but
 *  limited to in_nodes subtrees!
 */
+kukit.dom.childOf = function(element, ancestor) {
+    while (element = element.parentNode)
+        if (element == ancestor)
+            return true;
+    return false;
+};
+
 kukit.dom.cssQuery = function(selector, in_nodes) {
     // to eliminate possible errors
     if (typeof(in_nodes) != 'undefined' && in_nodes == null) {
         throw 'Selection error in kukit.dom.cssQuery';
     }
     // global scope, always.
-    var result = cssQuery(selector);
-    // This is very bad. However the binding makes sure that
-    // nodes once bound will never be bound again
-    // (also, noticed the following issue: cssQuery, when called
-    // on an element, does not check the element itself.)
+    var rawresult = cssQuery(selector);
+    return rawresult;
+    var result = [];
+
+    // filter out all elements which are not descendant of the elements in
+    // the in_nodes array
+    if (in_nodes == null)
+        return rawresult;
+
+    if (rawresult.length > 0) {
+        for (var i=0; i < rawresult.length; i++) {
+            for (var j=0; j < in_nodes.length; j++) {
+                var element = rawresult[i];
+                if (kukit.dom.childOf(element, in_nodes[j])) {
+                    result.push(element);
+                    break;
+                }
+            }
+        }
+    }
+
     return result;
 };
 


More information about the Kukit-checkins mailing list