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..2fb69728e5b9b71b82d8c2b20f27327c51641314 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,9 @@ 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) { |
+ assert(index >= 0 && index < this.length, 'Invalid index'); |
}, this); |
- if (!isIndexesValid) |
- throw Error('Invalid index, ' + indexes[i]); |
for (var i = 0; i < indexes.length; i++) { |
var e = new Event('change'); |
@@ -276,8 +275,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 +381,7 @@ 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. |
+ * @return {function(*, *): number} Compare function. |
* @private |
*/ |
createCompareFunction_: function(field) { |
@@ -396,14 +395,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) { |