Skip to content

Commit

Permalink
Rename isCustomComponent to isCustomElement
Browse files Browse the repository at this point in the history
That's the technical term.
  • Loading branch information
sebmarkbage committed Mar 30, 2023
1 parent 2af6c9c commit 5ddcfd2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
31 changes: 12 additions & 19 deletions packages/react-dom-bindings/src/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import {
} from './CSSPropertyOperations';
import {HTML_NAMESPACE, getIntrinsicNamespace} from './DOMNamespaces';
import {getPropertyInfo} from '../shared/DOMProperty';
import isCustomComponent from '../shared/isCustomComponent';
import isCustomElement from '../shared/isCustomElement';
import possibleStandardNames from '../shared/possibleStandardNames';
import {validateProperties as validateARIAProperties} from '../shared/ReactDOMInvalidARIAHook';
import {validateProperties as validateInputProperties} from '../shared/ReactDOMNullInputValuePropHook';
Expand Down Expand Up @@ -264,7 +264,7 @@ function setProp(
tag: string,
key: string,
value: mixed,
isCustomComponentTag: boolean,
isCustomElementTag: boolean,
props: any,
): void {
switch (key) {
Expand Down Expand Up @@ -390,7 +390,7 @@ function setProp(
warnForInvalidEventListener(key, value);
}
} else {
if (isCustomComponentTag) {
if (isCustomElementTag) {
if (enableCustomElementPropertySupport) {
setValueForPropertyOnCustomComponent(domElement, key, value);
} else {
Expand Down Expand Up @@ -653,7 +653,7 @@ export function setInitialProperties(
}
// defaultChecked and defaultValue are ignored by setProp
default: {
// TODO: If the `is` prop is specified, this should go through the isCustomComponentTag flow.
// TODO: If the `is` prop is specified, this should go through the isCustomElementTag flow.
setProp(domElement, tag, propKey, propValue, false, props);
}
}
Expand All @@ -662,8 +662,8 @@ export function setInitialProperties(
}
}

const isCustomComponentTag =
enableCustomElementPropertySupport && isCustomComponent(tag, props);
const isCustomElementTag =
enableCustomElementPropertySupport && isCustomElement(tag, props);
for (const propKey in props) {
if (!props.hasOwnProperty(propKey)) {
continue;
Expand All @@ -672,7 +672,7 @@ export function setInitialProperties(
if (propValue == null) {
continue;
}
setProp(domElement, tag, propKey, propValue, isCustomComponentTag, props);
setProp(domElement, tag, propKey, propValue, isCustomElementTag, props);
}
}

Expand Down Expand Up @@ -949,7 +949,7 @@ export function updateProperties(
}
// defaultChecked and defaultValue are ignored by setProp
default: {
// TODO: If the `is` prop is specified, this should go through the isCustomComponentTag flow.
// TODO: If the `is` prop is specified, this should go through the isCustomElementTag flow.
setProp(domElement, tag, propKey, propValue, false, nextProps);
}
}
Expand All @@ -958,20 +958,13 @@ export function updateProperties(
}
}

const isCustomComponentTag =
enableCustomElementPropertySupport && isCustomComponent(tag, nextProps);
const isCustomElementTag =
enableCustomElementPropertySupport && isCustomElement(tag, nextProps);
// Apply the diff.
for (let i = 0; i < updatePayload.length; i += 2) {
const propKey = updatePayload[i];
const propValue = updatePayload[i + 1];
setProp(
domElement,
tag,
propKey,
propValue,
isCustomComponentTag,
nextProps,
);
setProp(domElement, tag, propKey, propValue, isCustomElementTag, nextProps);
}
}

Expand Down Expand Up @@ -1357,7 +1350,7 @@ export function diffHydratedProperties(
extraAttributeNames.add(attributes[i].name);
}
}
if (isCustomComponent(tag, props)) {
if (isCustomElement(tag, props)) {
diffHydratedCustomComponent(
domElement,
tag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
processDispatchQueue,
accumulateTwoPhaseListeners,
} from '../DOMPluginEventSystem';
import isCustomComponent from '../../shared/isCustomComponent';
import isCustomElement from '../../shared/isCustomElement';

function registerEvents() {
registerTwoPhaseEvent('onChange', [
Expand Down Expand Up @@ -312,7 +312,7 @@ function extractEvents(
} else if (
enableCustomElementPropertySupport &&
targetInst &&
isCustomComponent(targetInst.elementType, targetInst.memoizedProps)
isCustomElement(targetInst.elementType, targetInst.memoizedProps)
) {
getTargetInstFunc = getTargetInstForChangeEvent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import {BOOLEAN, getPropertyInfo} from './DOMProperty';
import {ATTRIBUTE_NAME_CHAR} from './isAttributeNameSafe';
import isCustomComponent from './isCustomComponent';
import isCustomElement from './isCustomElement';
import possibleStandardNames from './possibleStandardNames';
import hasOwnProperty from 'shared/hasOwnProperty';
import {enableCustomElementPropertySupport} from 'shared/ReactFeatureFlags';
Expand Down Expand Up @@ -308,7 +308,7 @@ function warnUnknownProperties(type, props, eventRegistry) {
}

export function validateProperties(type, props, eventRegistry) {
if (isCustomComponent(type, props)) {
if (isCustomElement(type, props)) {
return;
}
warnUnknownProperties(type, props, eventRegistry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

function isCustomComponent(tagName: string, props: Object): boolean {
function isCustomElement(tagName: string, props: Object): boolean {
if (tagName.indexOf('-') === -1) {
return typeof props.is === 'string';
}
Expand All @@ -30,4 +30,4 @@ function isCustomComponent(tagName: string, props: Object): boolean {
}
}

export default isCustomComponent;
export default isCustomElement;

0 comments on commit 5ddcfd2

Please sign in to comment.