diff options
Diffstat (limited to 'chromium/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js')
-rw-r--r-- | chromium/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/chromium/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js b/chromium/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js index 181936d7132..d524c5433cf 100644 --- a/chromium/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js +++ b/chromium/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js @@ -30,6 +30,9 @@ var AnchorAlignment = { AFTER_END: 2, }; +/** @const {string} */ +var DROPDOWN_ITEM_CLASS = 'dropdown-item'; + (function() { /** * Returns the point to start along the X or Y axis given a start and end @@ -118,6 +121,9 @@ Polymer({ /** @private {boolean} */ hasMousemoveListener_: false, + /** @private {?PolymerDomApi.ObserveHandle} */ + contentObserver_: null, + hostAttributes: { tabindex: 0, }, @@ -137,6 +143,10 @@ Polymer({ removeListeners_: function() { window.removeEventListener('resize', this.boundClose_); window.removeEventListener('popstate', this.boundClose_); + if (this.contentObserver_) { + Polymer.dom(this.$.contentNode).unobserveNodes(this.contentObserver_); + this.contentObserver_ = null; + } }, /** @@ -321,7 +331,7 @@ Polymer({ // Restore the scroll position. doc.scrollTop = scrollTop; doc.scrollLeft = scrollLeft; - this.addCloseListeners_(); + this.addListeners_(); }, /** @private */ @@ -369,13 +379,24 @@ Polymer({ /** * @private */ - addCloseListeners_: function() { + addListeners_: function() { this.boundClose_ = this.boundClose_ || function() { if (this.open) this.close(); }.bind(this); window.addEventListener('resize', this.boundClose_); window.addEventListener('popstate', this.boundClose_); + + this.contentObserver_ = + Polymer.dom(this.$.contentNode).observeNodes((info) => { + info.addedNodes.forEach((node) => { + if (node.classList && + node.classList.contains(DROPDOWN_ITEM_CLASS) && + !node.getAttribute('role')) { + node.setAttribute('role', 'menuitem'); + } + }); + }); }, }); })(); |