File tree 1 file changed +10
-2
lines changed
core/src/utils/input-shims/hacks
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,17 @@ export const relocateInput = (
18
18
}
19
19
} ;
20
20
21
- // TODO(FW-2832): type
22
21
export const isFocused = ( input : HTMLInputElement | HTMLTextAreaElement ) : boolean => {
23
- return input === ( input as any ) . getRootNode ( ) . activeElement ;
22
+ /**
23
+ * https://developer.mozilla.org/en-US/docs/Web/API/Node/getRootNode
24
+ * Calling getRootNode on an element in standard web page will return HTMLDocument.
25
+ * Calling getRootNode on an element inside of the Shadow DOM will return the associated ShadowRoot.
26
+ * Calling getRootNode on an element that is not attached to a document/shadow tree will return
27
+ * the root of the DOM tree it belongs to.
28
+ * isFocused is used for the hide-caret utility which only considers input/textarea elements
29
+ * that are present in the DOM, so we don't set types for that final case since since it does not apply.
30
+ */
31
+ return input === ( input . getRootNode ( ) as HTMLDocument | ShadowRoot ) . activeElement ;
24
32
} ;
25
33
26
34
const addClone = (
You can’t perform that action at this time.
0 commit comments