Last active
February 5, 2023 08:37
-
-
Save egorvinogradov/5d7f8752a3843b99ed80b843986f3aa4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// INPUT | |
let text = '---'; | |
let input = document.querySelector('input'); | |
let event = new Event('input', { bubbles: true }); | |
let nativeInputValueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set; | |
nativeInputValueSetter.call(input, text); | |
input.dispatchEvent(event); | |
// TEXTAREA | |
let text = '---\n1\n2'; | |
let textarea = document.querySelector('textarea'); | |
let event = new Event('input', { bubbles: true }); | |
let nativeInputValueSetter = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value').set; | |
nativeInputValueSetter.call(textarea, text); | |
textarea.dispatchEvent(event); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment