MDL-33862 Ensure that a chooserspan exists before trying to set it up
[moodle.git] / course / yui / modchooser / modchooser.js
index 6b73e68..f2c7207 100644 (file)
@@ -100,6 +100,9 @@ YUI.add('moodle-course-modchooser', function(Y) {
         },
         _setup_for_section : function(section, sectionid) {
             var chooserspan = section.one(CSS.SECTIONMODCHOOSER);
+            if (!chooserspan) {
+                return;
+            }
             var chooserlink = Y.Node.create("<a href='#' />");
             chooserspan.get('children').each(function(node) {
                 chooserlink.appendChild(node);