( element: Element, value: ?string, defaultValue: ?string, )
| 62 | } |
| 63 | |
| 64 | export 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 | |
| 93 | export function initTextarea( |
| 94 | element: Element, |
no test coverage detected