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

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: Fixed previous comments 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..ff7770f295dab192796126ea14717729ed632d27 100644
--- a/ui/webui/resources/js/cr/ui/focus_manager.js
+++ b/ui/webui/resources/js/cr/ui/focus_manager.js
@@ -23,13 +23,13 @@ cr.define('cr.ui', function() {
/**
* Determines whether the |child| is a descendant of |parent| in the page's
* DOM.
- * @param {Element} parent The parent element to test.
- * @param {Element} child The child element to test.
+ * @param {Node} parent The parent element to test.
+ * @param {Node} child The child element to test.
* @return {boolean} True if |child| is a descendant of |parent|.
* @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 = [];
@@ -87,7 +89,7 @@ cr.define('cr.ui', function() {
* event. This differs from the native 'focus' event which is received by
* an element outside the page first, followed by a 'focus' on an element
* within the page after the FocusManager has intervened.
- * @param {Element} element The element that has received focus.
+ * @param {EventTarget} element The element that has received focus.
* @private
*/
dispatchFocusEvent_: function(element) {
@@ -155,7 +157,8 @@ cr.define('cr.ui', function() {
onDocumentFocus_: function(event) {
Dan Beam 2014/07/24 04:27:54 var targetNode = /** @type {Node} */(event.target)
Vitaly Pavlenko 2014/07/24 18:54:29 Acknowledged.
// If the element being focused is a descendant of the currently visible
// page, focus is valid.
- if (this.isDescendantOf_(this.getFocusParent(), event.target)) {
+ if (this.isDescendantOf_(this.getFocusParent(),
+ /** @type {Node} */(event.target))) {
this.dispatchFocusEvent_(event.target);
return;
}

Powered by Google App Engine
This is Rietveld 408576698