mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Move deepestShadowRoot to lib/dom to allow reuse
This commit is contained in:
parent
49b6e727f3
commit
465913f4be
2 changed files with 12 additions and 10 deletions
|
@ -3,6 +3,7 @@ import { contentState, ModeName } from "@src/content/state_content"
|
|||
import Logger from "@src/lib/logging"
|
||||
import * as controller from "@src/lib/controller"
|
||||
import { KeyEventLike, ParserResponse } from "@src/lib/keyseq"
|
||||
import { deepestShadowRoot } from "@src/lib/dom"
|
||||
|
||||
import * as hinting from "@src/content/hinting"
|
||||
import * as gobblemode from "@src/parsers/gobblemode"
|
||||
|
@ -93,16 +94,6 @@ class KeyCanceller {
|
|||
|
||||
export const canceller = new KeyCanceller()
|
||||
|
||||
/** Recursively resolves an active shadow DOM element. */
|
||||
function deepestShadowRoot(sr: ShadowRoot|null): ShadowRoot|null {
|
||||
if (sr === null) return sr
|
||||
let shadowRoot = sr
|
||||
while (shadowRoot.activeElement.shadowRoot != null) {
|
||||
shadowRoot = shadowRoot.activeElement.shadowRoot
|
||||
}
|
||||
return shadowRoot
|
||||
}
|
||||
|
||||
/** Accepts keyevents, resolves them to maps, maps to exstrs, executes exstrs */
|
||||
function* ParserController() {
|
||||
const parsers: {
|
||||
|
|
|
@ -683,3 +683,14 @@ export function simulateClick(target: HTMLElement) {
|
|||
focus(target)
|
||||
}
|
||||
}
|
||||
|
||||
/** Recursively resolves an active shadow DOM element. */
|
||||
export function deepestShadowRoot(sr: ShadowRoot|null): ShadowRoot|null {
|
||||
if (sr === null) return sr
|
||||
let shadowRoot = sr
|
||||
while (shadowRoot.activeElement.shadowRoot != null) {
|
||||
shadowRoot = shadowRoot.activeElement.shadowRoot
|
||||
}
|
||||
return shadowRoot
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue