setReactInputValue function infrastructure exported ✓ 100.0%

Last updated: 2026-03-04T23:21:38.390Z

Metrics

LOC: 25 Complexity: 6 Params: 3 Coverage: 100.0% (8/8 lines, 0x executed)

Signature

setReactInputValue( input: HTMLInputElement | HTMLTextAreaElement, value: string, ): : void

Summary

Dispatches React-compatible input events. Antd uses React synthetic events — we need to set the value via the native setter and dispatch properly.

Source Code

export function setReactInputValue(
  input: HTMLInputElement | HTMLTextAreaElement,
  value: string,
): void {
  const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
    window.HTMLInputElement.prototype,
    "value",
  )?.set;
  const nativeTextAreaValueSetter = Object.getOwnPropertyDescriptor(
    window.HTMLTextAreaElement.prototype,
    "value",
  )?.set;

  if (input instanceof HTMLInputElement && nativeInputValueSetter) {
    nativeInputValueSetter.call(input, value);
  } else if (
    input instanceof HTMLTextAreaElement &&
    nativeTextAreaValueSetter
  ) {
    nativeTextAreaValueSetter.call(input, value);
  }

  input.dispatchEvent(new Event("input", { bubbles: true }));
  input.dispatchEvent(new Event("change", { bubbles: true }));
}

No outgoing dependencies.

Impact (Incoming)

graph LR setReactInputValue["setReactInputValue"] matches["matches"] fill["fill"] matches -->|uses| setReactInputValue fill -->|calls| setReactInputValue matches -->|uses| setReactInputValue fill -->|calls| setReactInputValue style setReactInputValue fill:#dbeafe,stroke:#2563eb,stroke-width:2px click setReactInputValue "924fcd707043186b.html" click matches "697a9d97bb027c9d.html" click fill "119d6c7da53bca2c.html"
SourceType
matches uses
fill calls
matches uses
fill calls