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

Function postMountWrapper

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

Source from the content-addressed store, hash-verified

1852 }
1853 }
1854 function postMountWrapper(element, props, isHydrating) {
1855 var node = element; // Do not assign value if it is already set. This prevents user text input
1856 // from being lost during SSR hydration.
1857
1858 if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) {
1859 var type = props.type;
1860 var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the
1861 // default value provided by the browser. See: #12872
1862
1863 if (isButton && (props.value === undefined || props.value === null)) {
1864 return;
1865 }
1866
1867 var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input
1868 // from being lost during SSR hydration.
1869
1870 if (!isHydrating) {
1871 {
1872 // When syncing the value attribute, the value property should use
1873 // the wrapperState._initialValue property. This uses:
1874 //
1875 // 1. The value React property when present
1876 // 2. The defaultValue React property when present
1877 // 3. An empty string
1878 if (initialValue !== node.value) {
1879 node.value = initialValue;
1880 }
1881 }
1882 }
1883
1884 {
1885 // Otherwise, the value attribute is synchronized to the property,
1886 // so we assign defaultValue to the same thing as the value property
1887 // assignment step above.
1888 node.defaultValue = initialValue;
1889 }
1890 } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
1891 // this is needed to work around a chrome bug where setting defaultChecked
1892 // will sometimes influence the value of checked (even after detachment).
1893 // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416
1894 // We need to temporarily unset name to avoid disrupting radio button groups.
1895
1896
1897 var name = node.name;
1898
1899 if (name !== '') {
1900 node.name = '';
1901 }
1902
1903 {
1904 // When syncing the checked attribute, both the checked property and
1905 // attribute are assigned at the same time using defaultChecked. This uses:
1906 //
1907 // 1. The checked React property when present
1908 // 2. The defaultChecked React property when present
1909 // 3. Otherwise, false
1910 node.defaultChecked = !node.defaultChecked;
1911 node.defaultChecked = !!node._wrapperState.initialChecked;

Callers 2

setInitialPropertiesFunction · 0.70
diffHydratedPropertiesFunction · 0.70

Calls 1

toStringFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…