MCPcopy Create free account
hub / github.com/plotly/dash / updateWrapper

Function updateWrapper

dash/deps/react-dom@18.3.1.js:1793–1853  ·  view source on GitHub ↗
(element, props)

Source from the content-addressed store, hash-verified

1791 }
1792 }
1793 function updateWrapper(element, props) {
1794 var node = element;
1795
1796 {
1797 var controlled = isControlled(props);
1798
1799 if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) {
1800 error('A component is changing an uncontrolled input to be controlled. ' + 'This is likely caused by the value changing from undefined to ' + 'a defined value, which should not happen. ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components');
1801
1802 didWarnUncontrolledToControlled = true;
1803 }
1804
1805 if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) {
1806 error('A component is changing a controlled input to be uncontrolled. ' + 'This is likely caused by the value changing from a defined to ' + 'undefined, which should not happen. ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components');
1807
1808 didWarnControlledToUncontrolled = true;
1809 }
1810 }
1811
1812 updateChecked(element, props);
1813 var value = getToStringValue(props.value);
1814 var type = props.type;
1815
1816 if (value != null) {
1817 if (type === 'number') {
1818 if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible.
1819 // eslint-disable-next-line
1820 node.value != value) {
1821 node.value = toString(value);
1822 }
1823 } else if (node.value !== toString(value)) {
1824 node.value = toString(value);
1825 }
1826 } else if (type === 'submit' || type === 'reset') {
1827 // Submit/reset inputs need the attribute removed completely to avoid
1828 // blank-text buttons.
1829 node.removeAttribute('value');
1830 return;
1831 }
1832
1833 {
1834 // When syncing the value attribute, the value comes from a cascade of
1835 // properties:
1836 // 1. The value React property
1837 // 2. The defaultValue React property
1838 // 3. Otherwise there should be no change
1839 if (props.hasOwnProperty('value')) {
1840 setDefaultValue(node, props.type, value);
1841 } else if (props.hasOwnProperty('defaultValue')) {
1842 setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
1843 }
1844 }
1845
1846 {
1847 // When syncing the checked attribute, it only changes when it needs
1848 // to be removed, such as transitioning from a checkbox into a text input
1849 if (props.checked == null && props.defaultChecked != null) {
1850 node.defaultChecked = !!props.defaultChecked;

Callers 3

restoreControlledStateFunction · 0.70
updateNamedCousinsFunction · 0.70
updatePropertiesFunction · 0.70

Calls 6

isControlledFunction · 0.70
errorFunction · 0.70
updateCheckedFunction · 0.70
getToStringValueFunction · 0.70
toStringFunction · 0.70
setDefaultValueFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…