- commit
- a3696512e521f2c9b2120cc18636a5aebc83b321
- parent
- 1bb712422c712541bb4588eb7e057f930c565430
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2015-08-31 06:55
use _.forEach more consistently
Diffstat
| M | src/muu-dom-helpers.js | 10 | +++++----- |
| M | src/muu-js-helpers.js | 26 | +++++++++++++------------- |
| M | src/muu-template.js | 6 | +++--- |
3 files changed, 21 insertions, 21 deletions
diff --git a/src/muu-dom-helpers.js b/src/muu-dom-helpers.js
@@ -166,13 +166,13 @@ define("muu-dom-helpers", ['muu-js-helpers'], function(_) {
166 166 * @param {string} value
167 167 */
168 168 $.setRadio = function(options, value) {
169 -1 for (var i = 0; i < options.length; i++) {
170 -1 if (options[i].value === value) {
171 -1 options[i].checked = true;
-1 169 _.forEach(options, function(option) {
-1 170 if (option.value === value) {
-1 171 option.checked = true;
172 172 } else {
173 -1 options[i].checked = false;
-1 173 option.checked = false;
174 174 }
175 -1 }
-1 175 });
176 176 };
177 177
178 178 return $;
diff --git a/src/muu-js-helpers.js b/src/muu-js-helpers.js
@@ -106,9 +106,9 @@ define('muu-js-helpers', [], function() {
106 106 }
107 107
108 108 var results = [];
109 -1 for (var i = 0; i < array.length; i++) {
110 -1 results.push(fn(array[i]));
111 -1 }
-1 109 _.forEach(array, function(item) {
-1 110 results.push(fn(item));
-1 111 });
112 112 return results;
113 113 };
114 114
@@ -124,11 +124,11 @@ define('muu-js-helpers', [], function() {
124 124 }
125 125
126 126 var results = [];
127 -1 for (var i = 0; i < array.length; i++) {
128 -1 if (fn(array[i])) {
129 -1 results.push(array[i]);
-1 127 _.forEach(array, function(item) {
-1 128 if (fn(item)) {
-1 129 results.push(item);
130 130 }
131 -1 }
-1 131 });
132 132 return results;
133 133 };
134 134
@@ -139,13 +139,13 @@ define('muu-js-helpers', [], function() {
139 139 */
140 140 _.union = function(arrays) {
141 141 var results = [];
142 -1 for (var i = 0; i < arrays.length; i++) {
143 -1 for (var j = 0; j < arrays[i].length; j++) {
144 -1 if (_.indexOf(results, arrays[i][j]) === -1) {
145 -1 results.push(arrays[i][j]);
-1 142 _.forEach(arrays, function(array) {
-1 143 _.forEach(array, function(item) {
-1 144 if (_.indexOf(results, item) === -1) {
-1 145 results.push(item);
146 146 }
147 -1 }
148 -1 }
-1 147 });
-1 148 });
149 149 return results;
150 150 };
151 151
diff --git a/src/muu-template.js b/src/muu-template.js
@@ -129,9 +129,9 @@ define('muu-template', ['muu-js-helpers', 'muu-dom-helpers'], function(_, $) {
129 129 }
130 130 } else {
131 131 if (_.isArray(value)) {
132 -1 for (var i = 0; i < value.length; i++) {
133 -1 result += inner.render(value[i]);
134 -1 }
-1 132 _.forEach(value, function(item) {
-1 133 result += inner.render(item);
-1 134 });
135 135 } else if (value) {
136 136 result += inner.render(data);
137 137 }