MDL-57604 mod_assign: fix empty case in user selector
authorDan Poltawski <dan@moodle.com>
Wed, 18 Jan 2017 07:42:52 +0000 (07:42 +0000)
committerDan Poltawski <dan@moodle.com>
Wed, 18 Jan 2017 07:47:00 +0000 (07:47 +0000)
Sadly the js arguments object gives an arguments.length of 1 when
no arguments are passed, so we have to explicitly check for it.

mod/assign/amd/build/participant_selector.min.js
mod/assign/amd/src/participant_selector.js

index 671a70a..01f1ea5 100644 (file)
Binary files a/mod/assign/amd/build/participant_selector.min.js and b/mod/assign/amd/build/participant_selector.min.js differ
index 60b6816..b2cc28d 100644 (file)
@@ -95,8 +95,14 @@ define(['core/ajax', 'jquery', 'core/templates'], function(ajax, $, templates) {
                 // Do the dance for $.when()
                 return $.when.apply($, promises);
             }).then(function() {
-                // Undo the $.when() dance from arguments object into an array..
-                var users = Array.prototype.slice.call(arguments);
+                var users = [];
+
+                // Determine if we've been passed any arguments..
+                if (arguments[0]) {
+                    // Undo the $.when() dance from arguments object into an array..
+                    users = Array.prototype.slice.call(arguments);
+                }
+
                 success(users);
             }).catch(failure);
         }