[rhmessaging-commits] rhmessaging commits: r3300 - mgmt/trunk/wooly/resources.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Thu Apr 16 09:32:55 EDT 2009


Author: eallen
Date: 2009-04-16 09:32:55 -0400 (Thu, 16 Apr 2009)
New Revision: 3300

Modified:
   mgmt/trunk/wooly/resources/wooly.js
Log:
Do a deep search in xmlGetElementById in case id is not a direct decendant of parent.

Modified: mgmt/trunk/wooly/resources/wooly.js
===================================================================
--- mgmt/trunk/wooly/resources/wooly.js	2009-04-16 12:42:02 UTC (rev 3299)
+++ mgmt/trunk/wooly/resources/wooly.js	2009-04-16 13:32:55 UTC (rev 3300)
@@ -211,18 +211,26 @@
     }
 
     function xmlGetElementById(parent, id) {
-       var children = parent.childNodes;
-       if (children) {
-           for (var i=0; i<children.length; i++) {
-               var child = children.item(i);
-               if (child.nodeType == 1) {
-                   if (id == child.getAttribute("id")) {
-                       return child;
-                   }
-               }
-           }
-       }
-       return null;
+        var child = parent.firstChild;
+        // loop through siblings first
+        while (child) {
+            if (child.nodeType == 1) {
+                if (child.getAttribute("id") == id)
+                    return child;
+            }
+            child = child.nextSibling;
+        }
+        // then do a deep look at relatives
+        var child = parent.firstChild;
+        while (child) {
+            if (child.nodeType == 1) {
+                var progeny = xmlGetElementById(child, id);
+                if (progeny)
+                    return progeny;
+            }
+            child = child.nextSibling;
+        }
+        return null;
     } 
 
     function copyNode(node) {




More information about the rhmessaging-commits mailing list