function update(field, value, form) {
        if (value === undefined) {
            // undefined values should not be filled, but are always considered successful
            return true;
        }

        if (!value.length) {
            return false;
        }

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

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

        // 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 }));
        }

        // truncate the value if required by the field
        if (el.maxLength > 0) {
            value = value.substr(0, el.maxLength);
        }

        // Set the field value
        let initialValue = el.value || el.getAttribute("value");
        el.setAttribute("value", value);
        el.value = value;

        // 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 }));
        }

        // 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
        el.dispatchEvent(new Event("blur", { bubbles: true }));
        return true;
    }
Update a form field value

@since 3.0.0

@param object     field Field to update
@param string     value Value to set
@param DOMElement form  Form for which to set the given field
@return bool Whether the update succeeded