Autofill: re-set the field value if necessary (#182)
This commit is contained in:
@@ -409,6 +409,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the field value
|
// Set the field value
|
||||||
|
let initialValue = el.value || el.getAttribute("value");
|
||||||
el.setAttribute("value", value);
|
el.setAttribute("value", value);
|
||||||
el.value = value;
|
el.value = value;
|
||||||
|
|
||||||
@@ -417,6 +418,13 @@
|
|||||||
el.dispatchEvent(new Event(eventName, { bubbles: true }));
|
el.dispatchEvent(new Event(eventName, { bubbles: true }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// re-set value if unchanged after firing post-fill events
|
||||||
|
// (in case of sabotage by the site's own event handlers)
|
||||||
|
if ((el.value || el.getAttribute("value")) === initialValue) {
|
||||||
|
el.setAttribute("value", value);
|
||||||
|
el.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
// Finally unfocus the element
|
// Finally unfocus the element
|
||||||
el.dispatchEvent(new Event("blur", { bubbles: true }));
|
el.dispatchEvent(new Event("blur", { bubbles: true }));
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user