mirror of
https://github.com/MontFerret/ferret.git
synced 2025-01-16 03:21:03 +02:00
Allows simulated clicks to be canceled (#222)
User-generated mouse clicks are cancelable (and thus preventDefault() works), but the simulated MouseEvents were not cancelable. This led to some sites to have different behavior between user-generated and simulated clicks. See https://developer.mozilla.org/en-US/docs/Web/Events/click.
This commit is contained in:
parent
f97dd97a36
commit
61933caec9
@ -386,7 +386,7 @@ func (doc *HTMLDocument) ClickBySelector(selector values.String) (values.Boolean
|
||||
return false;
|
||||
}
|
||||
|
||||
var evt = new window.MouseEvent('click', { bubbles: true });
|
||||
var evt = new window.MouseEvent('click', { bubbles: true, cancelable: true });
|
||||
el.dispatchEvent(evt);
|
||||
|
||||
return true;
|
||||
@ -417,7 +417,7 @@ func (doc *HTMLDocument) ClickBySelectorAll(selector values.String) (values.Bool
|
||||
}
|
||||
|
||||
elements.forEach((el) => {
|
||||
var evt = new window.MouseEvent('click', { bubbles: true });
|
||||
var evt = new window.MouseEvent('click', { bubbles: true, cancelable: true });
|
||||
el.dispatchEvent(evt);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user