Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,28 +380,41 @@
}

// Focus the input element first
var el = find(field, form);
let el = find(field, form);
if (!el) {
return false;
}
var eventNames = ["click", "focus"];
eventNames.forEach(function(eventName) {
for (let eventName of ["click", "focus"]) {
el.dispatchEvent(new Event(eventName, { bubbles: true }));
});
}

// Focus may have triggered unvealing a true input, find it again
el = find(field, form);
if (!el) {
return false;
}

// Now set the value and unfocus
// Focus the potentially new element again
for (let eventName of ["click", "focus"]) {
el.dispatchEvent(new Event(eventName, { bubbles: true }));
}

// Send some keyboard events indicating that value modification has started (no associated keycode)
for (let eventName of ["keydown", "keypress", "keyup", "input", "change"]) {
el.dispatchEvent(new Event(eventName, { bubbles: true }));
}

// Set the field value
el.setAttribute("value", value);
el.value = value;
var eventNames = ["keypress", "keydown", "keyup", "input", "blur", "change"];
eventNames.forEach(function(eventName) {

// Send the keyboard events again indicating that value modification has finished (no associated keycode)
for (let eventName of ["keydown", "keypress", "keyup", "input", "change"]) {
el.dispatchEvent(new Event(eventName, { bubbles: true }));
});
}

// Finally unfocus the element
el.dispatchEvent(new Event("blur", { bubbles: true }));
return true;
}

Expand Down