Created
August 14, 2020 00:55
-
-
Save samthor/34e3ef00bdcecf6dc7cbc8738fb4524f to your computer and use it in GitHub Desktop.
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
/** | |
* @param {!Element=} | |
* @return {!Array<!Element>} containing focused element, deepest first | |
*/ | |
function getActive(t = document.activeElement || document.body) { | |
if (t.activeElement) { | |
t = t.activeElement; | |
} | |
if (t.shadowRoot) { | |
return [...getActive(t.shadowRoot), t]; | |
} | |
return [t]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment