MCPcopy Index your code
hub / github.com/microsoft/SandDance / updateNamedCousins

Function updateNamedCousins

docs/external/js/react-dom.development.js:2117–2164  ·  view source on GitHub ↗
(rootNode, props)

Source from the content-addressed store, hash-verified

2115 }
2116
2117 function updateNamedCousins(rootNode, props) {
2118 var name = props.name;
2119
2120 if (props.type === 'radio' && name != null) {
2121 var queryRoot = rootNode;
2122
2123 while (queryRoot.parentNode) {
2124 queryRoot = queryRoot.parentNode;
2125 } // If `rootNode.form` was non-null, then we could try `form.elements`,
2126 // but that sometimes behaves strangely in IE8. We could also try using
2127 // `form.getElementsByName`, but that will only return direct children
2128 // and won't include inputs that use the HTML5 `form=` attribute. Since
2129 // the input might not even be in a form. It might not even be in the
2130 // document. Let's just use the local `querySelectorAll` to ensure we don't
2131 // miss anything.
2132
2133
2134 var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]');
2135
2136 for (var i = 0; i < group.length; i++) {
2137 var otherNode = group[i];
2138
2139 if (otherNode === rootNode || otherNode.form !== rootNode.form) {
2140 continue;
2141 } // This will throw if radio buttons rendered by different copies of React
2142 // and the same name are rendered into the same form (same as #1939).
2143 // That's probably okay; we don't support it just as we don't support
2144 // mixing React radio buttons with non-React ones.
2145
2146
2147 var otherProps = getFiberCurrentPropsFromNode$1(otherNode);
2148
2149 if (!otherProps) {
2150 {
2151 throw Error( "ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported." );
2152 }
2153 } // We need update the tracked value on the named cousin since the value
2154 // was changed but the input saw no event or value set
2155
2156
2157 updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that
2158 // was previously checked to update will cause it to be come re-checked
2159 // as appropriate.
2160
2161 updateWrapper(otherNode, otherProps);
2162 }
2163 }
2164 } // In Chrome, assigning defaultValue to certain input types triggers input validation.
2165 // For number inputs, the display value loses trailing decimal points. For email inputs,
2166 // Chrome raises "The specified value <x> is not a valid email address".
2167 //

Callers 1

restoreControlledStateFunction · 0.85

Calls 3

updateValueIfChangedFunction · 0.85
updateWrapperFunction · 0.85

Tested by

no test coverage detected