Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Unified Diff: ui/webui/resources/js/cr/ui/focus_manager.js

Issue 418663002: Typecheck JS files for chrome://help before doing import transition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@json_to_pydict
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)) {

Powered by Google App Engine
This is Rietveld 408576698