Chromium Code Reviews| 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..8c7e6f3f31ed77191b1427d2bc2af263cbf237e7 100644 |
| --- a/ui/webui/resources/js/cr/ui/list.js |
| +++ b/ui/webui/resources/js/cr/ui/list.js |
| @@ -112,46 +112,53 @@ 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; |
|
bondd
2014/10/28 22:29:57
Bad diff output. All I did was change
if (th
|
| - 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. |
|
Dan Beam
2014/10/29 01:37:14
@protected
bondd
2014/10/29 17:19:08
Done.
|
| + */ |
| + onSetDataModelComplete: function() { |
| + }, |
| /** |
| * Cached item for measuring the default item size by measureItem(). |