Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 30, 2023
1 parent e7c0bcf commit 8dcb4a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/useActiveElement/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { defaultWindow } from '../_configurable'

export interface UseActiveElementOptions extends ConfigurableWindow, ConfigurableDocumentOrShadowRoot {
/**
* Search actively deeply in shadow dom
* Search active element deeply inside shadow dom
*
* @default true
*/
deepActiveElement?: boolean
deep?: boolean
}

/**
Expand All @@ -23,13 +23,13 @@ export function useActiveElement<T extends HTMLElement>(
) {
const {
window = defaultWindow,
deepActiveElement = true,
deep = true,
} = options
const document = options.document ?? window?.document

const getDeepActiveElement = () => {
let element = document?.activeElement
if (deepActiveElement) {
if (deep) {
while (element?.shadowRoot)
element = element?.shadowRoot?.activeElement
}
Expand Down

0 comments on commit 8dcb4a2

Please sign in to comment.