]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from 1.7.
authorvyshane <vyshane>
Fri, 1 Dec 2006 02:40:47 +0000 (02:40 +0000)
committervyshane <vyshane>
Fri, 1 Dec 2006 02:40:47 +0000 (02:40 +0000)
lib/ajax/section_classes.js

index 10aa4bb6b032bb5ff3b87106a7813ad9b7871397..c475e2e2f3050afdd6effb5c18654c354315a34a 100755 (executable)
@@ -367,17 +367,15 @@ section_class.prototype.remove_resource = function(el) {
             }
         }
     }
-    //remove "text" nodes to keep DOM clean
-    var childIndex = null;
-    var childrenCount = this.resources_ul.childNodes.length; 
-    for (var i=0; i<childrenCount; i++) {
-        if (this.resources_ul.childNodes[i] == el.getEl()) {
-            childIndex = i;
-               }
-       }
-    if (childIndex > 0 && childIndex < this.resources_ul.childNodes.length) {
-        this.resources_ul.removeChild(this.resources_ul.childNodes[childIndex - 1]);
+    // Remove any extra text nodes to keep DOM clean.
+       var kids = el.getEl().parentNode.childNodes;
+       var i = kids.length;
+       while (i--) {
+               if (kids[i].nodeType == 3) {
+               kids[i].parentNode.removeChild(kids[i]);
+           }
        }
+
     YAHOO.log("Removing "+el.getEl().id);
     if (el.getEl().parentNode != null) {
         el.getEl().parentNode.removeChild(el.getEl());