diff --git a/lib/ajax/section_classes.js b/lib/ajax/section_classes.js
index <HASH>..<HASH> 100755
--- a/lib/ajax/section_classes.js
+++ b/lib/ajax/section_classes.js
@@ -849,7 +849,9 @@ resource_class.prototype.clear_move_markers = function(target) {
         resources = target.parentObj.resources;
     }
     for (var i=0; i<resources.length; i++) {
-        YAHOO.util.Dom.setStyle(resources[i].getEl().id, 'border', 'none');
+        if (resources[i].getEl() != null) {
+            YAHOO.util.Dom.setStyle(resources[i].getEl().id, 'border', 'none');
+        }
     }
 }
 
@@ -865,8 +867,10 @@ resource_class.prototype.onDragOver = function(e, ids) {
     } else if (target.is == 'section' && target.resources.length > 0) {
         // We need to have a border at the bottom of the last activity in
         // that section.
-        YAHOO.util.Dom.setStyle(target.resources[target.resources.length - 1].getEl().id,
+        if (target.resources[target.resources.length - 1].getEl() != null) {
+            YAHOO.util.Dom.setStyle(target.resources[target.resources.length - 1].getEl().id,
                 'border-bottom', '1px solid #BBB');
+        }
     }
 }
MDL-<I> Preventing the border from being assigned to label list elements. Merged from MOODLE_<I>_STABLE