[KSS-checkins] r42418 - kukit/kukit.js/branch/performance_improvement/kukit

reebalazs at codespeak.net reebalazs at codespeak.net
Sun Apr 29 12:08:24 CEST 2007


Author: reebalazs
Date: Sun Apr 29 12:08:24 2007
New Revision: 42418

Modified:
   kukit/kukit.js/branch/performance_improvement/kukit/dom.js
Log:
Change the cssQuery usage alternating, if base2 is present that one is used, otherwise use the old cssQuery code

Modified: kukit/kukit.js/branch/performance_improvement/kukit/dom.js
==============================================================================
--- kukit/kukit.js/branch/performance_improvement/kukit/dom.js	(original)
+++ kukit/kukit.js/branch/performance_improvement/kukit/dom.js	Sun Apr 29 12:08:24 2007
@@ -123,26 +123,54 @@
 *  really the query should start from the document root, but
 *  limited to in_nodes subtrees!
 */
+
+
 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.
+    return kukit.dom._cssQuery(selector, in_nodes);
+};
+
+/*
+ * Decide which query to use
+ */
+
+kukit.dom._cssQuery = function(selector, in_nodes) {
+    var USE_BASE2 = (typeof(base2) != 'undefined');
+    if (USE_BASE2) {
+        kukit.log('Using cssQuery from base2');
+        kukit.dom._cssQuery = kukit.dom._cssQuery_base2
+    } else {
+        kukit.log('Using original cssQuery');
+        kukit.dom._cssQuery = kukit.dom._cssQuery_orig
+    }
+    return kukit.dom._cssQuery(selector, in_nodes);
+};
 
+kukit.dom._cssQuery_base2 = function(selector, in_nodes) {
+    // global scope, always.
+    // 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 results = base2.DOM.Document.matchAll(document, selector);
     var nodes = [];
     for(var i = 0; i < results.length; i++) {
         nodes.push(results.item(i));
     }
-    
+    return nodes;
+};
 
-    // TODO: I am not sure if this comment below applies to base2
+kukit.dom._cssQuery_orig = function(selector, in_nodes) {
+    // global scope, always.
     // 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.)
-    return nodes;
+    var results = cssQuery(selector);
+    return results;
 };
 
 kukit.dom.focus = function(node) {


More information about the Kukit-checkins mailing list