| Index: ui/webui/resources/js/cr/ui/list.js
|
| diff --git a/ui/webui/resources/js/cr/ui/list.js b/ui/webui/resources/js/cr/ui/list.js
|
| index 36b3c355ba0a41222893516a720c3ab16c9fba38..ea8cba6ebeb1cf080ae6812328749819d6e2411d 100644
|
| --- a/ui/webui/resources/js/cr/ui/list.js
|
| +++ b/ui/webui/resources/js/cr/ui/list.js
|
| @@ -112,46 +112,54 @@ cr.define('cr.ui', function() {
|
| * @type {ArrayDataModel}
|
| */
|
| set dataModel(dataModel) {
|
| - if (this.dataModel_ != dataModel) {
|
| - if (!this.boundHandleDataModelPermuted_) {
|
| - this.boundHandleDataModelPermuted_ =
|
| - this.handleDataModelPermuted_.bind(this);
|
| - this.boundHandleDataModelChange_ =
|
| - this.handleDataModelChange_.bind(this);
|
| - }
|
| + if (this.dataModel_ == dataModel)
|
| + return;
|
|
|
| - if (this.dataModel_) {
|
| - this.dataModel_.removeEventListener(
|
| - 'permuted',
|
| - this.boundHandleDataModelPermuted_);
|
| - this.dataModel_.removeEventListener('change',
|
| - this.boundHandleDataModelChange_);
|
| - }
|
| + if (!this.boundHandleDataModelPermuted_) {
|
| + this.boundHandleDataModelPermuted_ =
|
| + this.handleDataModelPermuted_.bind(this);
|
| + this.boundHandleDataModelChange_ =
|
| + this.handleDataModelChange_.bind(this);
|
| + }
|
|
|
| - this.dataModel_ = dataModel;
|
| + if (this.dataModel_) {
|
| + this.dataModel_.removeEventListener(
|
| + 'permuted',
|
| + this.boundHandleDataModelPermuted_);
|
| + this.dataModel_.removeEventListener('change',
|
| + this.boundHandleDataModelChange_);
|
| + }
|
|
|
| - this.cachedItems_ = {};
|
| - this.cachedItemHeights_ = {};
|
| - this.selectionModel.clear();
|
| - if (dataModel)
|
| - this.selectionModel.adjustLength(dataModel.length);
|
| -
|
| - if (this.dataModel_) {
|
| - this.dataModel_.addEventListener(
|
| - 'permuted',
|
| - this.boundHandleDataModelPermuted_);
|
| - this.dataModel_.addEventListener('change',
|
| - this.boundHandleDataModelChange_);
|
| - }
|
| + this.dataModel_ = dataModel;
|
|
|
| - this.redraw();
|
| + this.cachedItems_ = {};
|
| + this.cachedItemHeights_ = {};
|
| + this.selectionModel.clear();
|
| + if (dataModel)
|
| + this.selectionModel.adjustLength(dataModel.length);
|
| +
|
| + if (this.dataModel_) {
|
| + this.dataModel_.addEventListener(
|
| + 'permuted',
|
| + this.boundHandleDataModelPermuted_);
|
| + this.dataModel_.addEventListener('change',
|
| + this.boundHandleDataModelChange_);
|
| }
|
| +
|
| + this.redraw();
|
| + this.onSetDataModelComplete();
|
| },
|
|
|
| get dataModel() {
|
| return this.dataModel_;
|
| },
|
|
|
| + /**
|
| + * Override to be notified when |this.dataModel| is set.
|
| + * @protected
|
| + */
|
| + onSetDataModelComplete: function() {
|
| + },
|
|
|
| /**
|
| * Cached item for measuring the default item size by measureItem().
|
|
|