Author: jvloothuis
Date: Sat Feb 17 21:35:59 2007
New Revision: 39140

Modified:
   kukit/kukit.js/trunk/kukit/selectorreg.js
Log:
Added a parent node selector which accepts a css selector to fetch


Modified: kukit/kukit.js/trunk/kukit/selectorreg.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/selectorreg.js   (original)
+++ kukit/kukit.js/trunk/kukit/selectorreg.js   Sat Feb 17 21:35:59 2007
@@ -132,5 +132,29 @@
     return nodes;
 });
 
+// Return a list of all nodes that match the css expression in the parent chain
+kukit.selectorTypesGlobalRegistry.register('parentnode', function(expr, node, 
orignode) {
+    var selectednodes = kukit.dom.cssQuery(expr);
 
+    var parentnodes = [];
+    var parentnode = orignode.parentNode;
+    while(parentnode.parentNode) {
+        parentnodes.push(parentnode);
+        parentnode = parentnode.parentNode;
+    }
 
+    // Filter the nodes so that only the ones in the parent chain remain
+    var results = [];
+    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