( element: Element, value: ?string, defaultValue: ?string, )
| 148 | } |
| 149 | |
| 150 | export function hydrateTextarea( |
| 151 | element: Element, |
| 152 | value: ?string, |
| 153 | defaultValue: ?string, |
| 154 | ): void { |
| 155 | const node: HTMLTextAreaElement = (element: any); |
| 156 | let initialValue = value; |
| 157 | if (initialValue == null) { |
| 158 | if (defaultValue == null) { |
| 159 | defaultValue = ''; |
| 160 | } |
| 161 | initialValue = defaultValue; |
| 162 | } |
| 163 | // Track the value that we last observed which is the hydrated value so |
| 164 | // that any change event that fires will trigger onChange on the actual |
| 165 | // current value. |
| 166 | const stringValue = toString(getToStringValue(initialValue)); |
| 167 | const changed = trackHydrated((node: any), stringValue, false); |
| 168 | if (changed) { |
| 169 | // If the current value is different, that suggests that the user |
| 170 | // changed it before hydration. Queue a replay of the change event. |
| 171 | queueChangeEvent(node); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | export function restoreControlledTextareaState( |
| 176 | element: Element, |
no test coverage detected