MDL-60012 form: improve clarity of elementsByName code
authorDavo Smith <davo.smith@synergy-learning.com>
Tue, 3 Oct 2017 08:06:54 +0000 (09:06 +0100)
committerDavo Smith <davo.smith@synergy-learning.com>
Tue, 3 Oct 2017 08:09:09 +0000 (09:09 +0100)
lib/form/form.js

index 81f2b3b..2eaea03 100644 (file)
@@ -96,7 +96,7 @@ if (typeof M.form.dependencyManager === 'undefined') {
                     allnames[name].push(node);
                 }
             });
-            this._nameCollections = [names, allnames];
+            this._nameCollections = {names: names, allnames: allnames};
         },
 
         /**
@@ -111,7 +111,7 @@ if (typeof M.form.dependencyManager === 'undefined') {
             if (includeGroups === undefined) {
                 includeGroups = false;
             }
-            var collection = (includeGroups ? 1 : 0);
+            var collection = (includeGroups ? 'allnames' : 'names');
 
             if (!this._nameCollections) {
                 this.initElementsByName();