Author: reebalazs
Date: Tue Jul 29 11:07:39 2008
New Revision: 56831

Modified:
   kukit/kukit.js/branch/ree-binding-improvements/kukit/dom.js
Log:
Also add necessary changes from -r52420 of 1.4 branch, to use new base2 api

Modified: kukit/kukit.js/branch/ree-binding-improvements/kukit/dom.js
==============================================================================
--- kukit/kukit.js/branch/ree-binding-improvements/kukit/dom.js (original)
+++ kukit/kukit.js/branch/ree-binding-improvements/kukit/dom.js Tue Jul 29 
11:07:39 2008
@@ -84,40 +84,53 @@
  * 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
+var _USE_BASE2 = (typeof(base2) != 'undefined');
+if (_USE_BASE2) {
+    // Base2 legacy version: matchAll has to be used
+    // Base2 recent version: querySelectorAll has to be used
+    var _USE_BASE2_LEGACY = (typeof(base2.DOM.Document.querySelectorAll) == 
'undefined');
+    if (! _USE_BASE2_LEGACY) {
+;;;     kukit.log('Using cssQuery from base2.');
+        var _cssQuery = function(selector, inNodes) {
+            // 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.querySelectorAll(document, 
selector);
+            var nodes = [];
+            for(var i = 0; i < results.length; i++) {
+                nodes.push(results.item(i));
+            }
+            return nodes;
+        };
     } 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;
-};
-
-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.)
-    var results = cssQuery(selector);
-    return results;
+;;;     kukit.log('Using cssQuery from base2. (Using legacy API 
document.matchAll)');
+        var _cssQuery = function(selector, inNodes) {
+            // 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;
+        };
+    };
+} else {
+;;;kukit.log('Using original cssQuery.');
+    var _cssQuery = function(selector, inNodes) {
+        // 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 = cssQuery(selector);
+        return results;
+    };
 };
 
 kukit.dom.focus = function(node) {
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to