-
-
Save kreo/b62b7aed344dee7b57da79ff0ba67356 to your computer and use it in GitHub Desktop.
Returns current active element, including shadow dom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns current active element, including shadow dom | |
* | |
* @return element or null | |
*/ | |
export function getNativeFocused(documentRef: Document): Element | null { | |
if (!documentRef.activeElement || !documentRef.activeElement.shadowRoot) { | |
return documentRef.activeElement; | |
} | |
let element = documentRef.activeElement.shadowRoot.activeElement; | |
while (element && element.shadowRoot) { | |
element = element.shadowRoot.activeElement; | |
} | |
return element; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment