Commit 711c45a1 authored by krb's avatar krb Committed by Commit bot

Stop checking for null selectionModel field.

It's apparent that the field is never null in this method, and if it were, we'd have to change much more. So make the code a little more clear and remove the test.

BUG=

Review URL: https://codereview.chromium.org/1617243004

Cr-Commit-Position: refs/heads/master@{#374658}
parent c1f90b64
...@@ -389,13 +389,12 @@ cr.define('options', function() { ...@@ -389,13 +389,12 @@ cr.define('options', function() {
*/ */
load_: function(languageCodes) { load_: function(languageCodes) {
// Preserve the original selected index. See comments below. // Preserve the original selected index. See comments below.
var originalSelectedIndex = (this.selectionModel ? var originalSelectedIndex = this.selectionModel.selectedIndex;
this.selectionModel.selectedIndex : -1);
this.dataModel = new ArrayDataModel(languageCodes); this.dataModel = new ArrayDataModel(languageCodes);
if (originalSelectedIndex >= 0 && if (originalSelectedIndex >= 0 &&
originalSelectedIndex < this.dataModel.length) { originalSelectedIndex < this.dataModel.length) {
// Restore the original selected index if the selected index is // 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. // the selected language after the languge is added or removed.
this.selectionModel.selectedIndex = originalSelectedIndex; this.selectionModel.selectedIndex = originalSelectedIndex;
// The lead index should be updated too. // The lead index should be updated too.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment