Skip to content

Commit

Permalink
Support prototype setter
Browse files Browse the repository at this point in the history
  • Loading branch information
perry-mitchell committed Apr 6, 2024
1 parent f02e902 commit 1fa60c7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions source/typing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ export async function typeIntoInput(input: HTMLInputElement, value: string): Pro
while (characters.length > 0) {
const char = characters.shift();
newValue = `${newValue}${char}`;
// Set using attribute
input.setAttribute("value", newValue);
// Set using native methods
const proto = Object.getPrototypeOf(input);
const protoSetter = Object.getOwnPropertyDescriptor(proto, "value").set;
nativeInputValueSetter.call(input, newValue);
if (protoSetter && nativeInputValueSetter !== protoSetter) {
protoSetter.call(input, newValue);
}
// Try react set (React 16)
const tracker = (input as any)._valueTracker;
if (tracker) {
Expand Down

0 comments on commit 1fa60c7

Please sign in to comment.