setNativeValue function

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

Metrics

LOC: 28 Complexity: 8 Params: 2

Signature

setNativeValue(element: HTMLElement, value: string): : void

Source Code

function setNativeValue(element: HTMLElement, value: string): void {
  // Trigger React/Vue/Angular change detection
  const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
    window.HTMLInputElement.prototype,
    "value",
  )?.set;

  const nativeTextAreaValueSetter = Object.getOwnPropertyDescriptor(
    window.HTMLTextAreaElement.prototype,
    "value",
  )?.set;

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

  // Dispatch events to notify frameworks
  element.dispatchEvent(new Event("input", { bubbles: true }));
  element.dispatchEvent(new Event("change", { bubbles: true }));
  element.dispatchEvent(new Event("blur", { bubbles: true }));
}

Dependencies (Outgoing)

graph LR setNativeValue["setNativeValue"] FieldType["FieldType"] FormField["FormField"] GenerationResult["GenerationResult"] SavedForm["SavedForm"] Settings["Settings"] AIContextPayload["AIContextPayload"] detectAllFieldsAsync["detectAllFieldsAsync"] resolveFieldValue["resolveFieldValue"] generateFieldValueViaProxy["generateFieldValueViaProxy"] isAvailableViaProxy["isAvailableViaProxy"] generateFormContextValuesViaProxy["generateFormContextValuesViaProxy"] FormContextFieldInput["FormContextFieldInput"] generateWithTensorFlow["generateWithTensorFlow"] getSettings["getSettings"] getIgnoredFieldsForUrl["getIgnoredFieldsForUrl"] setFillingInProgress["setFillingInProgress"] fillCustomComponent["fillCustomComponent"] extractCustomComponentValue["extractCustomComponentValue"] generate["generate"] deriveFieldValueFromTemplate["deriveFieldValueFromTemplate"] createLogger["createLogger"] logAuditFill["logAuditFill"] createProgressNotification["createProgressNotification"] setNativeValue -->|uses| FieldType setNativeValue -->|uses| FormField setNativeValue -->|uses| GenerationResult setNativeValue -->|uses| SavedForm setNativeValue -->|uses| Settings setNativeValue -->|uses| AIContextPayload setNativeValue -->|uses| detectAllFieldsAsync setNativeValue -->|uses| resolveFieldValue setNativeValue -->|uses| generateFieldValueViaProxy setNativeValue -->|uses| isAvailableViaProxy setNativeValue -->|uses| generateFormContextValuesViaProxy setNativeValue -->|uses| FormContextFieldInput setNativeValue -->|uses| generateWithTensorFlow setNativeValue -->|uses| getSettings setNativeValue -->|uses| getIgnoredFieldsForUrl setNativeValue -->|uses| setFillingInProgress setNativeValue -->|uses| fillCustomComponent setNativeValue -->|uses| extractCustomComponentValue setNativeValue -->|uses| generate setNativeValue -->|uses| deriveFieldValueFromTemplate setNativeValue -->|uses| createLogger setNativeValue -->|uses| logAuditFill setNativeValue -->|uses| createProgressNotification style setNativeValue fill:#dbeafe,stroke:#2563eb,stroke-width:2px click setNativeValue "334bd99609d7c37c.html" click FieldType "e49ed8a601306673.html" click FormField "85cdbded927c91b0.html" click GenerationResult "9ad440b3e1a4d329.html" click SavedForm "d0449098c37a67b9.html" click Settings "dbe5880af98e954d.html" click AIContextPayload "0fc42100b4c63fc1.html" click detectAllFieldsAsync "1b422b3353cdbe22.html" click resolveFieldValue "b0ea06e6c355d586.html" click generateFieldValueViaProxy "2891b09f976a40d3.html" click isAvailableViaProxy "50fafb201d8fc13e.html" click generateFormContextValuesViaProxy "bcc26b2fe7063f60.html" click FormContextFieldInput "6194fbe20dc11cf0.html" click generateWithTensorFlow "49e69a4b304badea.html" click getSettings "99db54620b94a08b.html" click getIgnoredFieldsForUrl "b907cee0f0a40b9c.html" click setFillingInProgress "5404cb0266e02c7f.html" click fillCustomComponent "fb27203fbaa0cd9b.html" click extractCustomComponentValue "e6339fe1023108e6.html" click generate "a1352a91ca2859ed.html" click deriveFieldValueFromTemplate "e619d5b7d403167a.html" click createLogger "70597a0a6b5e9ebb.html" click logAuditFill "221e9f6c8e5f6850.html" click createProgressNotification "2f3f7f6d24a2f425.html"

Impact (Incoming)

graph LR setNativeValue["setNativeValue"] applyValueToField["applyValueToField"] applyValueToField -->|calls| setNativeValue style setNativeValue fill:#dbeafe,stroke:#2563eb,stroke-width:2px click setNativeValue "334bd99609d7c37c.html" click applyValueToField "59a962012828c5cb.html"
SourceType
applyValueToField calls