Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit the meaning of "custom element" to not include is #26524

Merged
merged 7 commits into from
Mar 30, 2023
Merged
48 changes: 8 additions & 40 deletions packages/react-dom-bindings/src/client/DOMPropertyOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,6 @@ export function getValueForAttributeOnCustomComponent(
}
return expected === undefined ? undefined : null;
}
if (enableCustomElementPropertySupport && name === 'className') {
// className is a special cased property on the server to render as an attribute.
name = 'class';
}
const value = node.getAttribute(name);

if (enableCustomElementPropertySupport) {
Expand Down Expand Up @@ -448,11 +444,7 @@ export function setValueForPropertyOnCustomComponent(
name: string,
value: mixed,
) {
if (
enableCustomElementPropertySupport &&
name[0] === 'o' &&
name[1] === 'n'
) {
if (name[0] === 'o' && name[1] === 'n') {
const useCapture = name.endsWith('Capture');
const eventName = name.substr(2, useCapture ? name.length - 9 : undefined);

Expand All @@ -477,40 +469,16 @@ export function setValueForPropertyOnCustomComponent(
}
}

if (enableCustomElementPropertySupport && name in (node: any)) {
if (name in (node: any)) {
(node: any)[name] = value;
return;
}

if (isAttributeNameSafe(name)) {
// shouldRemoveAttribute
if (value === null) {
node.removeAttribute(name);
return;
}
switch (typeof value) {
case 'undefined':
case 'function':
case 'symbol': // eslint-disable-line
node.removeAttribute(name);
return;
case 'boolean': {
if (enableCustomElementPropertySupport) {
if (value === true) {
node.setAttribute(name, '');
return;
}
node.removeAttribute(name);
return;
}
}
}
if (__DEV__) {
checkAttributeStringCoercion(value, name);
}
node.setAttribute(
name,
enableTrustedTypesIntegration ? (value: any) : '' + (value: any),
);
if (value === true) {
node.setAttribute(name, '');
return;
}

// From here, it's the same as any attribute
setValueForAttribute(node, name, value);
}
Loading