Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: chrome/browser/resources/options/language_list.js

Issue 1617243004: Stop checking for null selectionModel field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bail if selectionModel not set Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/options/language_list.js
diff --git a/chrome/browser/resources/options/language_list.js b/chrome/browser/resources/options/language_list.js
index 1030a0ac70e449e6cd59f36bf21855a1f61d738e..462429536f24f5159339663d47c6916762efa116 100644
--- a/chrome/browser/resources/options/language_list.js
+++ b/chrome/browser/resources/options/language_list.js
@@ -388,23 +388,19 @@ cr.define('options', function() {
* @private
*/
load_: function(languageCodes) {
+ if (!this.selectionModel)
Kevin Bailey 2016/01/26 15:00:40 Sorry, it was unclear to me what you preferred. So
Dan Beam 2016/01/26 19:38:53 I would prefer load_ only get called after being d
Kevin Bailey 2016/01/26 22:21:46 Done.
+ return;
// Preserve the original selected index. See comments below.
- var originalSelectedIndex = (this.selectionModel ?
- this.selectionModel.selectedIndex : -1);
+ var originalSelectedIndex = this.selectionModel.selectedIndex;
this.dataModel = new ArrayDataModel(languageCodes);
Dan Beam 2016/01/26 19:38:53 doing this.dataModel = ...; triggers an ES5 se
if (originalSelectedIndex >= 0 &&
originalSelectedIndex < this.dataModel.length) {
// Restore the original selected index if the selected index is
- // valid after the data model is loaded. This is neeeded to keep
+ // valid after the data model is loaded. This is needed to keep
// the selected language after the languge is added or removed.
this.selectionModel.selectedIndex = originalSelectedIndex;
// The lead index should be updated too.
this.selectionModel.leadIndex = originalSelectedIndex;
- } else if (this.dataModel.length > 0) {
- // Otherwise, select the first item if it's not empty.
- // Note that ListSingleSelectionModel won't select an item
- // automatically, hence we manually select the first item here.
- this.selectionModel.selectedIndex = 0;
Dan Beam 2016/01/26 19:38:53 revert this now
}
},
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698