(element, props, isHydrating)
| 5617 | } |
| 5618 | } |
| 5619 | function postMountWrapper(element, props, isHydrating) { |
| 5620 | var node = element; // Do not assign value if it is already set. This prevents user text input |
| 5621 | // from being lost during SSR hydration. |
| 5622 | |
| 5623 | if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) { |
| 5624 | var type = props.type; |
| 5625 | var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the |
| 5626 | // default value provided by the browser. See: #12872 |
| 5627 | |
| 5628 | if (isButton && (props.value === undefined || props.value === null)) { |
| 5629 | return; |
| 5630 | } |
| 5631 | |
| 5632 | var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input |
| 5633 | // from being lost during SSR hydration. |
| 5634 | |
| 5635 | if (!isHydrating) { |
| 5636 | { |
| 5637 | // When syncing the value attribute, the value property should use |
| 5638 | // the wrapperState._initialValue property. This uses: |
| 5639 | // |
| 5640 | // 1. The value React property when present |
| 5641 | // 2. The defaultValue React property when present |
| 5642 | // 3. An empty string |
| 5643 | if (initialValue !== node.value) { |
| 5644 | node.value = initialValue; |
| 5645 | } |
| 5646 | } |
| 5647 | } |
| 5648 | |
| 5649 | { |
| 5650 | // Otherwise, the value attribute is synchronized to the property, |
| 5651 | // so we assign defaultValue to the same thing as the value property |
| 5652 | // assignment step above. |
| 5653 | node.defaultValue = initialValue; |
| 5654 | } |
| 5655 | } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug |
| 5656 | // this is needed to work around a chrome bug where setting defaultChecked |
| 5657 | // will sometimes influence the value of checked (even after detachment). |
| 5658 | // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 |
| 5659 | // We need to temporarily unset name to avoid disrupting radio button groups. |
| 5660 | |
| 5661 | |
| 5662 | var name = node.name; |
| 5663 | |
| 5664 | if (name !== '') { |
| 5665 | node.name = ''; |
| 5666 | } |
| 5667 | |
| 5668 | { |
| 5669 | // When syncing the checked attribute, both the checked property and |
| 5670 | // attribute are assigned at the same time using defaultChecked. This uses: |
| 5671 | // |
| 5672 | // 1. The checked React property when present |
| 5673 | // 2. The defaultChecked React property when present |
| 5674 | // 3. Otherwise, false |
| 5675 | node.defaultChecked = !node.defaultChecked; |
| 5676 | node.defaultChecked = !!node._wrapperState.initialChecked; |
no test coverage detected