mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00
Support focus anchor button input details in find
The dom.ts is fixed a little to improve type check.
This commit is contained in:
parent
d76ad67fe1
commit
696510a50f
2 changed files with 17 additions and 6 deletions
|
@ -74,11 +74,20 @@ class FindHighlight extends HTMLSpanElement {
|
|||
inline: "center",
|
||||
})
|
||||
}
|
||||
let parentNode = this.range.startContainer.parentNode
|
||||
while (parentNode && !(parentNode instanceof HTMLAnchorElement)) {
|
||||
parentNode = parentNode.parentNode
|
||||
|
||||
let parentElement = this.range.startContainer.parentElement
|
||||
loop: while (parentElement) {
|
||||
switch (parentElement.nodeName.toLowerCase()) {
|
||||
case "a":
|
||||
case "input":
|
||||
case "button":
|
||||
case "details":
|
||||
parentElement.focus()
|
||||
break loop
|
||||
}
|
||||
parentElement = parentElement.parentElement
|
||||
}
|
||||
if (parentNode) parentNode.focus()
|
||||
|
||||
for (const node of this.children) {
|
||||
;(node as HTMLElement).style.background = `rgba(255,127,255,0.5)`
|
||||
}
|
||||
|
|
|
@ -222,8 +222,10 @@ export function isVisibleFilter(
|
|||
|
||||
*/
|
||||
export function isVisible(thing: Element | Range) {
|
||||
while (!(thing.getBoundingClientRect instanceof Function)) {
|
||||
thing = thing.parentElement
|
||||
if (thing instanceof Element) {
|
||||
while (typeof thing.getBoundingClientRect !== "function") {
|
||||
thing = thing.parentElement
|
||||
}
|
||||
}
|
||||
const clientRect = thing.getBoundingClientRect()
|
||||
switch (true) {
|
||||
|
|
Loading…
Add table
Reference in a new issue