mirror of
https://github.com/MontFerret/ferret.git
synced 2025-09-16 09:06:36 +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:
@@ -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);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user