Author: jvloothuis
Date: Sat Jul  7 00:41:43 2007
New Revision: 44816

Modified:
   kukit/kukit.js/trunk/kukit/selectorreg.js
Log:
Reverted extra feature for parentnode selecting surrounding nodes


Modified: kukit/kukit.js/trunk/kukit/selectorreg.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/selectorreg.js   (original)
+++ kukit/kukit.js/trunk/kukit/selectorreg.js   Sat Jul  7 00:41:43 2007
@@ -149,64 +149,28 @@
     return nodes;
 });
 
-// Return a list of all nodes that match the css expression in the
-// parent chain This selector can also return surrounding nodes by
-// passing in an expression with a "%" in it.
+// Return a list of all nodes that match the css expression in the parent chain
 kukit.selectorTypesGlobalRegistry.register('parentnode', function(expr, node) {
-    var expressions = expr.split('%');
-
-    ;;; if (expressions.length > 2) {
-    ;;;    throw 'Only one "%" allowed in parentnode selector: "' + expr + '"';
-    ;;; }
-
-    function parentnodes(node){
-       var nodes = [];
-       var parentnode = node;
-       while(parentnode.parentNode) {
-            nodes.push(parentnode);
-            parentnode = parentnode.parentNode;
-       }
-       return nodes;
-    }
-
-    function filternode(allowed, node){
-       for(var i=0; i<allowed.length; i++){
-           if(allowed[i] == node){
-               return node;
-           }
-       }
-    }
-
-    function filternodes(allowed, nodes){
-       var results = [];
-       for(var i=0; i<nodes.length; i++){
-           var node = filternode(allowed, nodes[i]);
-           if(node != null){
-               results.push(node);
-           }
-       }
-       return results;
+    var selectednodes = kukit.dom.cssQuery(expr);
+    var parentnodes = [];
+    var parentnode = node.parentNode;
+    while(parentnode.parentNode) {
+        parentnodes.push(parentnode);
+        parentnode = parentnode.parentNode;
     }
 
-    var selectednodes = kukit.dom.cssQuery(expressions[0]);
-    var parentchain = parentnodes(node.parentNode);
-
     // Filter the nodes so that only the ones in the parent chain remain
-    parentchain = filternodes(parentchain, selectednodes);
-
-    // If there is only a single expression just return the results
-    if(expressions.length == 1){
-       return parentchain;
-    }
-
-    // When searching for surrounding nodes use the second expression
-    var surroundingnodes = kukit.dom.cssQuery(expressions[1]);
     var results = [];
-    for(var i=0; i<surroundingnodes.length; i++){
-       var node = surroundingnodes[i];
-       if(filternodes(parentchain, parentnodes(node)) != null){
-           results.push(node);
-       }
+    for(var i=0; i<selectednodes.length; i++){
+        var inchain = false;
+        for(var j=0; j<parentnodes.length; j++){
+            if(selectednodes[i] === parentnodes[j]){
+                inchain = true;
+            }
+        }
+        if(inchain){
+            results.push(selectednodes[i]);
+        }
     }
     return results;
 });
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to