resolve #48 check focus and blur before call since the target can be HTMLDocument in firefox

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent fdda3c7e99
commit 384227d0df

View File

@@ -446,18 +446,22 @@ export class Replayer {
break; break;
} }
const event = new Event(MouseInteractions[d.type].toLowerCase()); const event = new Event(MouseInteractions[d.type].toLowerCase());
const target = mirror.getNode(d.id); let target = mirror.getNode(d.id);
if (!target) { if (!target) {
return this.warnNodeNotFound(d, d.id); return this.warnNodeNotFound(d, d.id);
} }
switch (d.type) { switch (d.type) {
case MouseInteractions.Blur: case MouseInteractions.Blur:
((target as Node) as HTMLElement).blur(); if (((target as Node) as HTMLElement).blur) {
((target as Node) as HTMLElement).blur();
}
break; break;
case MouseInteractions.Focus: case MouseInteractions.Focus:
((target as Node) as HTMLElement).focus({ if (((target as Node) as HTMLElement).focus) {
preventScroll: true, ((target as Node) as HTMLElement).focus({
}); preventScroll: true,
});
}
break; break;
case MouseInteractions.Click: case MouseInteractions.Click:
/** /**