Skip to content

Instantly share code, notes, and snippets.

@MarekZeman91
Last active May 9, 2022 10:36
Show Gist options
  • Save MarekZeman91/c34bca3f83050a5e84a086a34ffac44f to your computer and use it in GitHub Desktop.
Save MarekZeman91/c34bca3f83050a5e84a086a34ffac44f to your computer and use it in GitHub Desktop.
const setText = (input: HTMLInputElement, value: string): void => {
const prototype = Object.getPrototypeOf(input);
const valueSetter = Object.getOwnPropertyDescriptor(prototype, 'value').set;
valueSetter.call(input, value);
const init = { bubbles: true, cancelable: true };
input.dispatchEvent(new Event('change', init));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment