Chromium Code Reviews| Index: ui/webui/resources/js/cr/ui/focus_manager.js |
| diff --git a/ui/webui/resources/js/cr/ui/focus_manager.js b/ui/webui/resources/js/cr/ui/focus_manager.js |
| index c84277c93c26f89be806deeb87fb692bd24a69c3..c82ec30cc6961a8eaa55ea51e56d75280ab65d9a 100644 |
| --- a/ui/webui/resources/js/cr/ui/focus_manager.js |
| +++ b/ui/webui/resources/js/cr/ui/focus_manager.js |
| @@ -29,7 +29,7 @@ cr.define('cr.ui', function() { |
| * @private |
| */ |
| isDescendantOf_: function(parent, child) { |
| - return parent && !(parent === child) && parent.contains(child); |
| + return !!parent && !(parent === child) && parent.contains(child); |
| }, |
| /** |
| @@ -43,7 +43,7 @@ cr.define('cr.ui', function() { |
| /** |
| * Returns the elements on the page capable of receiving focus. |
| - * @return {Array.Element} The focusable elements. |
| + * @return {Array.<Element>} The focusable elements. |
| */ |
| getFocusableElements_: function() { |
| var focusableDiv = this.getFocusParent(); |
| @@ -52,7 +52,9 @@ cr.define('cr.ui', function() { |
| var treeWalker = document.createTreeWalker( |
| focusableDiv, |
| NodeFilter.SHOW_ELEMENT, |
| - { acceptNode: function(node) { |
| + /** @type {NodeFilter} */ |
| + ({ |
| + acceptNode: function(node) { |
| var style = window.getComputedStyle(node); |
| // Reject all hidden nodes. FILTER_REJECT also rejects these |
| // nodes' children, so non-hidden elements that are descendants of |
| @@ -70,7 +72,7 @@ cr.define('cr.ui', function() { |
| // Accept nodes that are non-hidden and focusable. |
| return NodeFilter.FILTER_ACCEPT; |
| } |
| - }, |
| + }), |
| false); |
| var focusable = []; |
| @@ -153,6 +155,7 @@ cr.define('cr.ui', function() { |
| * @private |
| */ |
| onDocumentFocus_: function(event) { |
| + event.target = /** @type {Element} */(event.target); |
|
Dan Beam
2014/07/23 22:09:24
this can be (and very well might be) a Document.
Vitaly Pavlenko
2014/07/24 01:09:31
Done.
|
| // If the element being focused is a descendant of the currently visible |
| // page, focus is valid. |
| if (this.isDescendantOf_(this.getFocusParent(), event.target)) { |