restoreControlledInputState() — react Function Reference
Architecture documentation for the restoreControlledInputState() function in ReactDOMInput.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD eb91f874_8ee4_2703_d333_d67f28ac1a0b["restoreControlledInputState()"] ebd36fdb_cc70_52b6_9971_bcace1958602["ReactDOMInput.js"] eb91f874_8ee4_2703_d333_d67f28ac1a0b -->|defined in| ebd36fdb_cc70_52b6_9971_bcace1958602 77f4e8f0_f9b0_3782_0fdd_8c9f87346e83["hydrateText()"] 77f4e8f0_f9b0_3782_0fdd_8c9f87346e83 -->|calls| eb91f874_8ee4_2703_d333_d67f28ac1a0b 859b1aa4_1e7b_dfa5_1e21_ba34a1a483ac["updateInput()"] eb91f874_8ee4_2703_d333_d67f28ac1a0b -->|calls| 859b1aa4_1e7b_dfa5_1e21_ba34a1a483ac 4da12b01_19ae_db73_2a8b_4f1a8096aca0["escapeSelectorAttributeValueInsideDoubleQuotes()"] eb91f874_8ee4_2703_d333_d67f28ac1a0b -->|calls| 4da12b01_19ae_db73_2a8b_4f1a8096aca0 c66d3317_2d86_a8d4_7629_44de9f6a564d["updateValueIfChanged()"] eb91f874_8ee4_2703_d333_d67f28ac1a0b -->|calls| c66d3317_2d86_a8d4_7629_44de9f6a564d style eb91f874_8ee4_2703_d333_d67f28ac1a0b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom-bindings/src/client/ReactDOMInput.js lines 383–462
export function restoreControlledInputState(element: Element, props: Object) {
const rootNode: HTMLInputElement = (element: any);
updateInput(
rootNode,
props.value,
props.defaultValue,
props.defaultValue,
props.checked,
props.defaultChecked,
props.type,
props.name,
);
const name = props.name;
if (props.type === 'radio' && name != null) {
let queryRoot: Element = rootNode;
while (queryRoot.parentNode) {
queryRoot = ((queryRoot.parentNode: any): Element);
}
// If `rootNode.form` was non-null, then we could try `form.elements`,
// but that sometimes behaves strangely in IE8. We could also try using
// `form.getElementsByName`, but that will only return direct children
// and won't include inputs that use the HTML5 `form=` attribute. Since
// the input might not even be in a form. It might not even be in the
// document. Let's just use the local `querySelectorAll` to ensure we don't
// miss anything.
if (__DEV__) {
checkAttributeStringCoercion(name, 'name');
}
const group = queryRoot.querySelectorAll(
'input[name="' +
escapeSelectorAttributeValueInsideDoubleQuotes('' + name) +
'"][type="radio"]',
);
for (let i = 0; i < group.length; i++) {
const otherNode = ((group[i]: any): HTMLInputElement);
if (otherNode === rootNode || otherNode.form !== rootNode.form) {
continue;
}
// This will throw if radio buttons rendered by different copies of React
// and the same name are rendered into the same form (same as #1939).
// That's probably okay; we don't support it just as we don't support
// mixing React radio buttons with non-React ones.
const otherProps: any = getFiberCurrentPropsFromNode(otherNode);
if (!otherProps) {
throw new Error(
'ReactDOMInput: Mixing React and non-React radio inputs with the ' +
'same `name` is not supported.',
);
}
// If this is a controlled radio button group, forcing the input that
// was previously checked to update will cause it to be come re-checked
// as appropriate.
updateInput(
otherNode,
otherProps.value,
otherProps.defaultValue,
otherProps.defaultValue,
otherProps.checked,
otherProps.defaultChecked,
otherProps.type,
otherProps.name,
);
}
// If any updateInput() call set .checked to true, an input in this group
// (often, `rootNode` itself) may have become unchecked
for (let i = 0; i < group.length; i++) {
const otherNode = ((group[i]: any): HTMLInputElement);
if (otherNode.form !== rootNode.form) {
continue;
}
updateValueIfChanged(otherNode);
}
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does restoreControlledInputState() do?
restoreControlledInputState() is a function in the react codebase, defined in packages/react-dom-bindings/src/client/ReactDOMInput.js.
Where is restoreControlledInputState() defined?
restoreControlledInputState() is defined in packages/react-dom-bindings/src/client/ReactDOMInput.js at line 383.
What does restoreControlledInputState() call?
restoreControlledInputState() calls 3 function(s): escapeSelectorAttributeValueInsideDoubleQuotes, updateInput, updateValueIfChanged.
What calls restoreControlledInputState()?
restoreControlledInputState() is called by 1 function(s): hydrateText.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free