Skip to content

Commit

Permalink
Update index.ts
Browse files Browse the repository at this point in the history
Compatible with shadow dom
  • Loading branch information
duoduoObama committed Jul 4, 2023
1 parent bddfbae commit 6edb184
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/core/useActiveElement/index.ts
Expand Up @@ -14,9 +14,16 @@ export interface UseActiveElementOptions extends ConfigurableWindow, Configurabl
export function useActiveElement<T extends HTMLElement>(options: UseActiveElementOptions = {}) {
const { window = defaultWindow } = options
const document = options.document ?? window?.document
const getDeepestActiveElement = () => {
let element = document?.activeElement;

Check failure on line 18 in packages/core/useActiveElement/index.ts

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon
while (element?.shadowRoot) {

Check failure on line 19 in packages/core/useActiveElement/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unnecessary { after 'while' condition
element = element?.shadowRoot?.activeElement;

Check failure on line 20 in packages/core/useActiveElement/index.ts

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 6 spaces but found 8

Check failure on line 20 in packages/core/useActiveElement/index.ts

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon
}
return element;

Check failure on line 22 in packages/core/useActiveElement/index.ts

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon
};

Check failure on line 23 in packages/core/useActiveElement/index.ts

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon
const activeElement = computedWithControl(
() => null,
() => document?.activeElement as T | null | undefined,
() => getDeepestActiveElement() as T | null | undefined,
)

if (window) {
Expand Down

0 comments on commit 6edb184

Please sign in to comment.