Skip to content

Commit 0b3b8a6

Browse files
authored
jsx: Remove unnecessary hasOwnProperty check (#28775)
Follow up to #28768. The modern JSX runtime (`jsx`) does not need to check if each prop is a direct property with `hasOwnProperty` because the compiler always passes a plain object. I'll leave the check in the old JSX runtime (`createElement`) since that one can be called manually with any kind of object, and if there were old user code that relied on this for some reason, it would be using that runtime.
1 parent e63918d commit 0b3b8a6

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

packages/react/src/jsx/ReactJSXElement.js

+4-12
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,8 @@ export function jsxProd(type, config, maybeKey) {
364364
// because in V8 it will deopt the object to dictionary mode.
365365
props = {};
366366
for (const propName in config) {
367-
if (
368-
hasOwnProperty.call(config, propName) &&
369-
// Skip over reserved prop names
370-
propName !== 'key' &&
371-
(enableRefAsProp || propName !== 'ref')
372-
) {
367+
// Skip over reserved prop names
368+
if (propName !== 'key' && (enableRefAsProp || propName !== 'ref')) {
373369
if (enableRefAsProp && !disableStringRefs && propName === 'ref') {
374370
props.ref = coerceStringRef(
375371
config[propName],
@@ -603,12 +599,8 @@ export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
603599
// because in V8 it will deopt the object to dictionary mode.
604600
props = {};
605601
for (const propName in config) {
606-
if (
607-
hasOwnProperty.call(config, propName) &&
608-
// Skip over reserved prop names
609-
propName !== 'key' &&
610-
(enableRefAsProp || propName !== 'ref')
611-
) {
602+
// Skip over reserved prop names
603+
if (propName !== 'key' && (enableRefAsProp || propName !== 'ref')) {
612604
if (enableRefAsProp && !disableStringRefs && propName === 'ref') {
613605
props.ref = coerceStringRef(
614606
config[propName],

0 commit comments

Comments
 (0)