Chromium Code Reviews| Index: chrome/browser/resources/settings/settings_action_menu.js |
| diff --git a/chrome/browser/resources/settings/settings_action_menu.js b/chrome/browser/resources/settings/settings_action_menu.js |
| index e584a5552abc0f37ff8c072ca997bee5776b2dcb..ab02e1e82fac5b8a1f73bba80f4b0fb08916fdaa 100644 |
| --- a/chrome/browser/resources/settings/settings_action_menu.js |
| +++ b/chrome/browser/resources/settings/settings_action_menu.js |
| @@ -13,12 +13,6 @@ Polymer({ |
| options_: null, |
| /** |
| - * Index of the currently focused item. |
| - * @private {number} |
| - */ |
| - focusedIndex_: -1, |
| - |
| - /** |
| * Reference to the bound window's resize listener, such that it can be |
| * removed on detach. |
| * @private {?Function} |
| @@ -94,10 +88,14 @@ Polymer({ |
| var nextOption = null; |
| var numOptions = this.options_.length; |
| + // Using |call| to call indexOf on a NodeList, without converting it to an |
| + // Array. |
|
Dan Beam
2016/10/25 00:56:10
don't really think this is a useful comment
dpapad
2016/10/25 01:27:51
Removed.
|
| + var focusedIndex = Array.prototype.indexOf.call( |
| + this.options_, this.root.activeElement); |
| + |
| do { |
| - this.focusedIndex_ = |
| - (numOptions + this.focusedIndex_ + step) % numOptions; |
| - nextOption = this.options_[this.focusedIndex_]; |
| + focusedIndex = (numOptions + focusedIndex + step) % numOptions; |
| + nextOption = this.options_[focusedIndex]; |
| if (nextOption.disabled || nextOption.hidden) |
| nextOption = null; |
| counter++; |
| @@ -119,23 +117,6 @@ Polymer({ |
| * @param {!Element} anchorElement |
| */ |
| showAt: function(anchorElement) { |
| - var rect = anchorElement.getBoundingClientRect(); |
| - |
| - // Ensure that the correct item is focused when the dialog is shown, by |
| - // setting the 'autofocus' attribute. |
| - this.focusedIndex_ = -1; |
| - var nextOption = this.getNextOption_(1); |
| - |
| - /** @suppress {checkTypes} */ |
| - (function(options) { |
| - options.forEach(function(option) { |
| - option.removeAttribute('autofocus'); |
| - }); |
| - })(this.options_); |
| - |
| - if (nextOption) |
| - nextOption.setAttribute('autofocus', true); |
| - |
| this.onWindowResize_ = this.onWindowResize_ || function() { |
| if (this.open) |
| this.close(); |
| @@ -144,6 +125,7 @@ Polymer({ |
| this.showModal(); |
| + var rect = anchorElement.getBoundingClientRect(); |
| if (new settings.DirectionDelegateImpl().isRtl()) { |
| var right = window.innerWidth - rect.left - this.offsetWidth; |
| this.style.right = right + 'px'; |