| 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..9254dc378fbcabb7f46ab2a4ea134c39cc3945b6 100644
|
| --- a/ui/webui/resources/js/cr/ui/array_data_model.js
|
| +++ b/ui/webui/resources/js/cr/ui/array_data_model.js
|
| @@ -5,6 +5,14 @@
|
| /**
|
| * @fileoverview This is a data model representin
|
| */
|
| +
|
| +// The include directives are put into Javascript-style comments to prevent
|
| +// parsing errors in non-flattened mode. The flattener still sees them.
|
| +// Note that this makes the flattener to comment out the first line of the
|
| +// included file but that's all right since any javascript file should start
|
| +// with a copyright comment anyway.
|
| +
|
| +//<include src="../../assert.js">
|
|
|
| cr.define('cr.ui', function() {
|
| /** @const */ var EventTarget = cr.EventTarget;
|
| @@ -14,7 +22,7 @@
|
| * 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 +70,8 @@
|
| /**
|
| * 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 +136,7 @@
|
| * 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 +211,7 @@
|
| *
|
| * 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 +258,9 @@
|
| * @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 +283,8 @@
|
|
|
| /**
|
| * 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 +389,7 @@
|
| * 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 +403,12 @@
|
| 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) {
|
|
|