( node: ElementWithValueTracker, initialValue: string, initialChecked: boolean, )
| 130 | } |
| 131 | |
| 132 | export function trackHydrated( |
| 133 | node: ElementWithValueTracker, |
| 134 | initialValue: string, |
| 135 | initialChecked: boolean, |
| 136 | ): boolean { |
| 137 | // For hydration, the initial value is not the current value but the value |
| 138 | // that we last observed which is what the initial server render was. |
| 139 | if (getTracker(node)) { |
| 140 | return false; |
| 141 | } |
| 142 | |
| 143 | let valueField: 'checked' | 'value'; |
| 144 | let expectedValue; |
| 145 | if (isCheckable(node)) { |
| 146 | valueField = 'checked'; |
| 147 | // eslint-disable-next-line react-internal/safe-string-coercion |
| 148 | expectedValue = '' + (initialChecked: any); |
| 149 | } else { |
| 150 | valueField = 'value'; |
| 151 | expectedValue = initialValue; |
| 152 | } |
| 153 | const currentValue = |
| 154 | // eslint-disable-next-line react-internal/safe-string-coercion |
| 155 | '' + |
| 156 | (// $FlowFixMe[prop-missing] |
| 157 | node[valueField]: any); |
| 158 | node._valueTracker = trackValueOnNode(node, valueField, expectedValue); |
| 159 | return currentValue !== expectedValue; |
| 160 | } |
| 161 | |
| 162 | export function updateValueIfChanged(node: ElementWithValueTracker): boolean { |
| 163 | if (!node) { |
no test coverage detected