Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * The |name| is shown in the gui. The |value| us use to set or compare with | 6 * The |name| is shown in the gui. The |value| us use to set or compare with |
| 7 * the preference value. | 7 * the preference value. |
| 8 * @typedef {{ | 8 * @typedef {{ |
| 9 * name: string, | 9 * name: string, |
| 10 * value: (number|string) | 10 * value: (number|string) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 var prefValue = this.pref.value; | 97 var prefValue = this.pref.value; |
| 98 var option = this.menuOptions.find(function(menuItem) { | 98 var option = this.menuOptions.find(function(menuItem) { |
| 99 return menuItem.value == prefValue; | 99 return menuItem.value == prefValue; |
| 100 }); | 100 }); |
| 101 | 101 |
| 102 // Need to wait for the dom-repeat to render, before assigning a value to | 102 // Need to wait for the dom-repeat to render, before assigning a value to |
| 103 // |selected_|, otherwise select#value is not populated correctly. | 103 // |selected_|, otherwise select#value is not populated correctly. |
| 104 this.async(function() { | 104 this.async(function() { |
| 105 this.selected_ = option == undefined ? | 105 var newSelected = option == undefined ? |
| 106 this.notFoundValue_ : | 106 this.notFoundValue_ : |
| 107 Settings.PrefUtil.prefToString(assert(this.pref)); | 107 Settings.PrefUtil.prefToString(assert(this.pref)); |
| 108 | |
| 109 // Ensure Polymer recognizes that selected_ changes. | |
| 110 if (newSelected == this.selected_) | |
| 111 this.selected_ = ''; | |
|
stevenjb
2016/10/21 20:16:40
Eww. Can we do:
if( == )
this.notifyPath('select
michaelpg
2016/10/25 00:35:15
Found a correct-er fix and rebased this patch on t
| |
| 112 this.selected_ = newSelected; | |
| 108 }.bind(this)); | 113 }.bind(this)); |
| 109 }, | 114 }, |
| 110 | 115 |
| 111 /** | 116 /** |
| 112 * @param {string} selected | 117 * @param {string} selected |
| 113 * @return {boolean} | 118 * @return {boolean} |
| 114 * @private | 119 * @private |
| 115 */ | 120 */ |
| 116 isSelectedNotFound_: function(selected) { | 121 isSelectedNotFound_: function(selected) { |
| 117 return this.menuOptions.length > 0 && selected == this.notFoundValue_; | 122 return this.menuOptions.length > 0 && selected == this.notFoundValue_; |
| 118 }, | 123 }, |
| 119 | 124 |
| 120 /** | 125 /** |
| 121 * @return {boolean} | 126 * @return {boolean} |
| 122 * @private | 127 * @private |
| 123 */ | 128 */ |
| 124 shouldDisableMenu_: function() { | 129 shouldDisableMenu_: function() { |
| 125 return this.disabled || this.menuOptions === null || | 130 return this.disabled || this.menuOptions === null || |
| 126 this.menuOptions.length == 0; | 131 this.menuOptions.length == 0; |
| 127 }, | 132 }, |
| 128 }); | 133 }); |
| OLD | NEW |