Chromium Code Reviews| Index: ui/webui/resources/js/cr/ui/array_data_model.js |
| diff --git a/ui/webui/resources/js/cr/ui/array_data_model.js b/ui/webui/resources/js/cr/ui/array_data_model.js |
| index f8d649ccb27a9dadcda113122c0c9a2605cd648a..36912f44ee0fe6efbd96b3ed6454279aa61e9d01 100644 |
| --- a/ui/webui/resources/js/cr/ui/array_data_model.js |
| +++ b/ui/webui/resources/js/cr/ui/array_data_model.js |
| @@ -14,7 +14,7 @@ cr.define('cr.ui', function() { |
| * initial indexes of elements for each position in sorted array. |
| * @param {!Array} array The underlying array. |
| * @constructor |
| - * @extends {EventTarget} |
| + * @extends {cr.EventTarget} |
| */ |
| function ArrayDataModel(array) { |
| this.array_ = array; |
| @@ -62,7 +62,8 @@ cr.define('cr.ui', function() { |
| /** |
| * Sets compare function for given field. |
| * @param {string} field The field to set compare function. |
| - * @param {function(*, *): number} Compare function to set for given field. |
| + * @param {function(*, *): number} compareFunction Compare function to set |
| + * for given field. |
| */ |
| setCompareFunction: function(field, compareFunction) { |
| if (!this.compareFunctions_) { |
| @@ -127,7 +128,7 @@ cr.define('cr.ui', function() { |
| * the whole change. |
| * @param {number} index The index of the item to update. |
| * @param {number} deleteCount The number of items to remove. |
| - * @param {...*} The items to add. |
| + * @param {...*} var_args The items to add. |
| * @return {!Array} An array with the removed items. |
| */ |
| splice: function(index, deleteCount, var_args) { |
| @@ -202,7 +203,7 @@ cr.define('cr.ui', function() { |
| * |
| * This dispatches a splice event. |
| * |
| - * @param {...*} The items to append. |
| + * @param {...*} var_args The items to append. |
| * @return {number} The new length of the model. |
| */ |
| push: function(var_args) { |
| @@ -249,11 +250,11 @@ cr.define('cr.ui', function() { |
| * @param {Array.<number>} indexes The index list of items to update. |
| */ |
| updateIndexes: function(indexes) { |
| - var isIndexesValid = indexes.every(function(index) { |
| - return 0 <= index && index < this.length; |
| + indexes.forEach(function(index) { |
| + if (!(0 <= index && index < this.length)) { |
| + throw Error('Invalid index, ' + index); |
| + } |
|
Dan Beam
2014/08/21 18:27:48
assert(index >= 0 && index < this.length, 'Invalid
Vitaly Pavlenko
2014/08/22 01:43:41
Done.
|
| }, this); |
| - if (!isIndexesValid) |
| - throw Error('Invalid index, ' + indexes[i]); |
| for (var i = 0; i < indexes.length; i++) { |
| var e = new Event('change'); |
| @@ -276,8 +277,8 @@ cr.define('cr.ui', function() { |
| /** |
| * Creates sort status with given field and direction. |
| - * @param {string} field Sort field. |
| - * @param {string} direction Sort direction. |
| + * @param {?string} field Sort field. |
| + * @param {?string} direction Sort direction. |
| * @return {!Object} Created sort status. |
| */ |
| createSortStatus: function(field, direction) { |
| @@ -382,7 +383,6 @@ cr.define('cr.ui', function() { |
| * Returns the function set as sortFunction for given field |
| * or default compare function |
| * @param {string} field Sort field. |
| - * @param {function(*, *): number} Compare function. |
| * @private |
| */ |
| createCompareFunction_: function(field) { |
| @@ -396,14 +396,12 @@ cr.define('cr.ui', function() { |
| return defaultValuesCompareFunction.call(null, a[field], b[field]); |
| } |
| } |
| - return compareFunction; |
| }, |
| /** |
| * Creates compare function for given field and direction. |
| * @param {string} field Sort field. |
| * @param {string} direction Sort direction. |
| - * @param {function(*, *): number} Compare function. |
| * @private |
| */ |
| sortFunction_: function(field, direction) { |