mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -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",
|
inline: "center",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
let parentNode = this.range.startContainer.parentNode
|
|
||||||
while (parentNode && !(parentNode instanceof HTMLAnchorElement)) {
|
let parentElement = this.range.startContainer.parentElement
|
||||||
parentNode = parentNode.parentNode
|
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) {
|
for (const node of this.children) {
|
||||||
;(node as HTMLElement).style.background = `rgba(255,127,255,0.5)`
|
;(node as HTMLElement).style.background = `rgba(255,127,255,0.5)`
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,8 +222,10 @@ export function isVisibleFilter(
|
||||||
|
|
||||||
*/
|
*/
|
||||||
export function isVisible(thing: Element | Range) {
|
export function isVisible(thing: Element | Range) {
|
||||||
while (!(thing.getBoundingClientRect instanceof Function)) {
|
if (thing instanceof Element) {
|
||||||
thing = thing.parentElement
|
while (typeof thing.getBoundingClientRect !== "function") {
|
||||||
|
thing = thing.parentElement
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const clientRect = thing.getBoundingClientRect()
|
const clientRect = thing.getBoundingClientRect()
|
||||||
switch (true) {
|
switch (true) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue