mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-02 10:56:00 +02:00
nanka iroiro
This commit is contained in:
23
src/client/scripts/focus.ts
Normal file
23
src/client/scripts/focus.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
export function focusPrev(el: Element | null, self = false) {
|
||||
if (el == null) return;
|
||||
if (!self) el = el.previousElementSibling;
|
||||
if (el) {
|
||||
if (el.hasAttribute('tabindex')) {
|
||||
(el as HTMLElement).focus();
|
||||
} else {
|
||||
focusPrev(el.previousElementSibling, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function focusNext(el: Element | null, self = false) {
|
||||
if (el == null) return;
|
||||
if (!self) el = el.nextElementSibling;
|
||||
if (el) {
|
||||
if (el.hasAttribute('tabindex')) {
|
||||
(el as HTMLElement).focus();
|
||||
} else {
|
||||
focusPrev(el.nextElementSibling, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user