Skip to content

Commit

Permalink
Rename initX to validateXProps and postInitX to initX
Browse files Browse the repository at this point in the history
Since the init is now just validation I rename those methods appropriately.

Since postInit is now just where initialization happens, that's just init.
  • Loading branch information
sebmarkbage committed Apr 9, 2023
1 parent b263fa3 commit 91f7014
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
26 changes: 13 additions & 13 deletions packages/react-dom-bindings/src/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ import {
setValueForNamespacedAttribute,
} from './DOMPropertyOperations';
import {
validateInputProps,
initInput,
postInitInput,
updateInputChecked,
updateInput,
restoreControlledInputState,
} from './ReactDOMInput';
import {postInitOption, validateOptionProps} from './ReactDOMOption';
import {initOption, validateOptionProps} from './ReactDOMOption';
import {
validateSelectProps,
initSelect,
postInitSelect,
restoreControlledSelectState,
updateSelect,
} from './ReactDOMSelect';
import {
validateTextareaProps,
initTextarea,
postInitTextarea,
updateTextarea,
restoreControlledTextareaState,
} from './ReactDOMTextarea';
Expand Down Expand Up @@ -866,8 +866,8 @@ export function setInitialProperties(
// TODO: Make sure we check if this is still unmounted or do any clean
// up necessary since we never stop tracking anymore.
track((domElement: any));
initInput(domElement, props);
postInitInput(domElement, props, false);
validateInputProps(domElement, props);
initInput(domElement, props, false);
return;
}
case 'select': {
Expand Down Expand Up @@ -896,8 +896,8 @@ export function setInitialProperties(
}
}
}
validateSelectProps(domElement, props);
initSelect(domElement, props);
postInitSelect(domElement, props);
return;
}
case 'textarea': {
Expand Down Expand Up @@ -942,8 +942,8 @@ export function setInitialProperties(
// TODO: Make sure we check if this is still unmounted or do any clean
// up necessary since we never stop tracking anymore.
track((domElement: any));
validateTextareaProps(domElement, props);
initTextarea(domElement, props);
postInitTextarea(domElement, props);
return;
}
case 'option': {
Expand All @@ -970,7 +970,7 @@ export function setInitialProperties(
}
}
}
postInitOption(domElement, props);
initOption(domElement, props);
return;
}
case 'dialog': {
Expand Down Expand Up @@ -2319,13 +2319,13 @@ export function diffHydratedProperties(
// TODO: Make sure we check if this is still unmounted or do any clean
// up necessary since we never stop tracking anymore.
track((domElement: any));
initInput(domElement, props);
validateInputProps(domElement, props);
// For input and textarea we current always set the value property at
// post mount to force it to diverge from attributes. However, for
// option and select we don't quite do the same thing and select
// is not resilient to the DOM state changing so we don't do that here.
// TODO: Consider not doing this for input and textarea.
postInitInput(domElement, props, true);
initInput(domElement, props, true);
break;
case 'option':
validateOptionProps(domElement, props);
Expand All @@ -2337,7 +2337,7 @@ export function diffHydratedProperties(
// We listen to this event in case to ensure emulated bubble
// listeners still fire for the invalid event.
listenToNonDelegatedEvent('invalid', domElement);
initSelect(domElement, props);
validateSelectProps(domElement, props);
break;
case 'textarea':
if (__DEV__) {
Expand All @@ -2349,8 +2349,8 @@ export function diffHydratedProperties(
// TODO: Make sure we check if this is still unmounted or do any clean
// up necessary since we never stop tracking anymore.
track((domElement: any));
validateTextareaProps(domElement, props);
initTextarea(domElement, props);
postInitTextarea(domElement, props);
break;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom-bindings/src/client/ReactDOMInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let didWarnCheckedDefaultChecked = false;
* See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
*/

export function initInput(element: Element, props: Object) {
export function validateInputProps(element: Element, props: Object) {
if (__DEV__) {
// Normally we check for undefined and null the same, but explicitly specifying both
// properties, at all is probably worth warning for. We could move this either direction
Expand Down Expand Up @@ -160,7 +160,7 @@ export function updateInput(element: Element, props: Object) {
}
}

export function postInitInput(
export function initInput(
element: Element,
props: Object,
isHydrating: boolean,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom-bindings/src/client/ReactDOMOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function validateOptionProps(element: Element, props: Object) {
}
}

export function postInitOption(element: Element, props: Object) {
export function initOption(element: Element, props: Object) {
// value="" should make a value attribute (#6219)
if (props.value != null) {
element.setAttribute('value', toString(getToStringValue(props.value)));
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom-bindings/src/client/ReactDOMSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function updateOptions(
* selected.
*/

export function initSelect(element: Element, props: Object) {
export function validateSelectProps(element: Element, props: Object) {
if (__DEV__) {
checkSelectPropTypes(props);
if (
Expand All @@ -142,7 +142,7 @@ export function initSelect(element: Element, props: Object) {
}
}

export function postInitSelect(element: Element, props: Object) {
export function initSelect(element: Element, props: Object) {
const node: HTMLSelectElement = (element: any);
node.multiple = !!props.multiple;
const value = props.value;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom-bindings/src/client/ReactDOMTextarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let didWarnValDefaultVal = false;
* `defaultValue` if specified, or the children content (deprecated).
*/

export function initTextarea(element: Element, props: Object) {
export function validateTextareaProps(element: Element, props: Object) {
if (__DEV__) {
if (
props.value !== undefined &&
Expand Down Expand Up @@ -82,7 +82,7 @@ export function updateTextarea(element: Element, props: Object) {
}
}

export function postInitTextarea(element: Element, props: Object) {
export function initTextarea(element: Element, props: Object) {
const node: HTMLTextAreaElement = (element: any);

let initialValue = props.value;
Expand Down

0 comments on commit 91f7014

Please sign in to comment.