MCPcopy
hub / github.com/facebook/react / updateTextarea

Function updateTextarea

packages/react-dom-bindings/src/client/ReactDOMTextarea.js:64–91  ·  view source on GitHub ↗
(
  element: Element,
  value: ?string,
  defaultValue: ?string,
)

Source from the content-addressed store, hash-verified

62}
63
64export function updateTextarea(
65 element: Element,
66 value: ?string,
67 defaultValue: ?string,
68) {
69 const node: HTMLTextAreaElement = (element: any);
70 if (value != null) {
71 // Cast `value` to a string to ensure the value is set correctly. While
72 // browsers typically do this as necessary, jsdom doesn't.
73 const newValue = toString(getToStringValue(value));
74 // To avoid side effects (such as losing text selection), only set value if changed
75 if (newValue !== node.value) {
76 node.value = newValue;
77 }
78 // TOOO: This should respect disableInputAttributeSyncing flag.
79 if (defaultValue == null) {
80 if (node.defaultValue !== newValue) {
81 node.defaultValue = newValue;
82 }
83 return;
84 }
85 }
86 if (defaultValue != null) {
87 node.defaultValue = toString(getToStringValue(defaultValue));
88 } else {
89 node.defaultValue = '';
90 }
91}
92
93export function initTextarea(
94 element: Element,

Callers 2

updatePropertiesFunction · 0.90

Calls 2

toStringFunction · 0.90
getToStringValueFunction · 0.90

Tested by

no test coverage detected