mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Dispatch more events on fill
This commit is contained in:
parent
f3379e6677
commit
1c7828eb86
1 changed files with 16 additions and 5 deletions
|
|
@ -672,12 +672,23 @@ kpxc.setValueWithChange = function(field, value, forced = false) {
|
|||
return;
|
||||
}
|
||||
|
||||
const dispatchLegacyEvent = function(elem, eventName) {
|
||||
const legacyEvent = elem.ownerDocument.createEvent('Event');
|
||||
legacyEvent.initEvent(eventName, true, false);
|
||||
elem.dispatchEvent(legacyEvent);
|
||||
};
|
||||
|
||||
field.focus();
|
||||
field.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, cancelable: false }));
|
||||
field.dispatchEvent(new KeyboardEvent('keypress', { bubbles: true, cancelable: false }));
|
||||
field.dispatchEvent(new KeyboardEvent('keyup', { bubbles: true, cancelable: false }));
|
||||
field.dispatchEvent(new Event('input', { bubbles: true, cancelable: false }));
|
||||
field.dispatchEvent(new Event('change', { bubbles: true, cancelable: false }));
|
||||
field.value = value;
|
||||
field.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
field.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
field.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, cancelable: false, key: '', char: '' }));
|
||||
field.dispatchEvent(new KeyboardEvent('keypress', { bubbles: true, cancelable: false, key: '', char: '' }));
|
||||
field.dispatchEvent(new KeyboardEvent('keyup', { bubbles: true, cancelable: false, key: '', char: '' }));
|
||||
|
||||
// Some pages will not accept the value change without dispatching events directly to the document
|
||||
dispatchLegacyEvent(field, 'input');
|
||||
dispatchLegacyEvent(field, 'change');
|
||||
};
|
||||
|
||||
// Returns true if site is ignored
|
||||
|
|
|
|||
Loading…
Reference in a new issue