Skip to content

Commit 38b5f5d

Browse files
committed
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. DiffTrain build for commit 0b3b8a6.
1 parent 86065f6 commit 38b5f5d

File tree

8 files changed

+21
-36
lines changed

8 files changed

+21
-36
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<ec56b30d76b5a69544373d710da9f9aa>>
10+
* @generated SignedSource<<89ab70059fbd85b63bf80748a754cb73>>
1111
*/
1212

1313
"use strict";
@@ -1327,11 +1327,8 @@ if (__DEV__) {
13271327
props = {};
13281328

13291329
for (var propName in config) {
1330-
if (
1331-
hasOwnProperty.call(config, propName) && // Skip over reserved prop names
1332-
propName !== "key" &&
1333-
propName !== "ref"
1334-
) {
1330+
// Skip over reserved prop names
1331+
if (propName !== "key" && propName !== "ref") {
13351332
{
13361333
props[propName] = config[propName];
13371334
}

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<f9829995214271eca2ce345a7f2da74a>>
10+
* @generated SignedSource<<793e5defde71fd400afe9a6583a3e6cb>>
1111
*/
1212

1313
"use strict";
@@ -1363,11 +1363,8 @@ if (__DEV__) {
13631363
props = {};
13641364

13651365
for (var propName in config) {
1366-
if (
1367-
hasOwnProperty.call(config, propName) && // Skip over reserved prop names
1368-
propName !== "key" &&
1369-
propName !== "ref"
1370-
) {
1366+
// Skip over reserved prop names
1367+
if (propName !== "key" && propName !== "ref") {
13711368
{
13721369
props[propName] = config[propName];
13731370
}

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-prod.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<d24a690e1d6994ec3438bae6ba3ca710>>
10+
* @generated SignedSource<<8e9fc6c30cb3a1a336d8532aee527031>>
1111
*/
1212

1313
"use strict";
@@ -32,7 +32,6 @@ function formatProdErrorMessage(code) {
3232
}
3333
var disableDefaultPropsExceptForClasses =
3434
dynamicFlagsUntyped.disableDefaultPropsExceptForClasses,
35-
hasOwnProperty = Object.prototype.hasOwnProperty,
3635
ReactCurrentOwner =
3736
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;
3837
function jsxProd(type, config, maybeKey) {
@@ -54,8 +53,7 @@ function jsxProd(type, config, maybeKey) {
5453
}
5554
maybeKey = {};
5655
for (var propName in config)
57-
hasOwnProperty.call(config, propName) &&
58-
"key" !== propName &&
56+
"key" !== propName &&
5957
"ref" !== propName &&
6058
(maybeKey[propName] = config[propName]);
6159
if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) {

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-profiling.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<d24a690e1d6994ec3438bae6ba3ca710>>
10+
* @generated SignedSource<<8e9fc6c30cb3a1a336d8532aee527031>>
1111
*/
1212

1313
"use strict";
@@ -32,7 +32,6 @@ function formatProdErrorMessage(code) {
3232
}
3333
var disableDefaultPropsExceptForClasses =
3434
dynamicFlagsUntyped.disableDefaultPropsExceptForClasses,
35-
hasOwnProperty = Object.prototype.hasOwnProperty,
3635
ReactCurrentOwner =
3736
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;
3837
function jsxProd(type, config, maybeKey) {
@@ -54,8 +53,7 @@ function jsxProd(type, config, maybeKey) {
5453
}
5554
maybeKey = {};
5655
for (var propName in config)
57-
hasOwnProperty.call(config, propName) &&
58-
"key" !== propName &&
56+
"key" !== propName &&
5957
"ref" !== propName &&
6058
(maybeKey[propName] = config[propName]);
6159
if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) {

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<c641be89261f73fa6d57361dd219a15d>>
10+
* @generated SignedSource<<0301515ac101d5b3682c687183627ea7>>
1111
*/
1212

1313
"use strict";
@@ -26,7 +26,7 @@ if (__DEV__) {
2626
}
2727
var dynamicFlagsUntyped = require("ReactNativeInternalFeatureFlags");
2828

29-
var ReactVersion = "19.0.0-canary-33300bbd";
29+
var ReactVersion = "19.0.0-canary-91afb935";
3030

3131
// ATTENTION
3232
// When adding new symbols to this file,
@@ -1749,11 +1749,8 @@ if (__DEV__) {
17491749
props = {};
17501750

17511751
for (var propName in config) {
1752-
if (
1753-
hasOwnProperty.call(config, propName) && // Skip over reserved prop names
1754-
propName !== "key" &&
1755-
propName !== "ref"
1756-
) {
1752+
// Skip over reserved prop names
1753+
if (propName !== "key" && propName !== "ref") {
17571754
{
17581755
props[propName] = config[propName];
17591756
}

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<c127deb722db5c1322641d4b8f8d0b01>>
10+
* @generated SignedSource<<68b673436655d580c5a9bcf2c90d6d00>>
1111
*/
1212

1313
"use strict";
@@ -117,8 +117,7 @@ function jsxProd(type, config, maybeKey) {
117117
(ref = coerceStringRef(ref, ReactCurrentOwner.current, type)));
118118
maybeKey = {};
119119
for (var propName in config)
120-
hasOwnProperty.call(config, propName) &&
121-
"key" !== propName &&
120+
"key" !== propName &&
122121
"ref" !== propName &&
123122
(maybeKey[propName] = config[propName]);
124123
if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) {
@@ -685,4 +684,4 @@ exports.useSyncExternalStore = function (
685684
exports.useTransition = function () {
686685
return ReactCurrentDispatcher.current.useTransition();
687686
};
688-
exports.version = "19.0.0-canary-78482d58";
687+
exports.version = "19.0.0-canary-2d37c214";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<5a164104e95b6f496fecb7036c4b4780>>
10+
* @generated SignedSource<<c327032e795f673af99163be781261f7>>
1111
*/
1212

1313
"use strict";
@@ -121,8 +121,7 @@ function jsxProd(type, config, maybeKey) {
121121
(ref = coerceStringRef(ref, ReactCurrentOwner.current, type)));
122122
maybeKey = {};
123123
for (var propName in config)
124-
hasOwnProperty.call(config, propName) &&
125-
"key" !== propName &&
124+
"key" !== propName &&
126125
"ref" !== propName &&
127126
(maybeKey[propName] = config[propName]);
128127
if (!disableDefaultPropsExceptForClasses && type && type.defaultProps) {
@@ -689,7 +688,7 @@ exports.useSyncExternalStore = function (
689688
exports.useTransition = function () {
690689
return ReactCurrentDispatcher.current.useTransition();
691690
};
692-
exports.version = "19.0.0-canary-cedf8410";
691+
exports.version = "19.0.0-canary-f3e1f261";
693692
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
694693
"function" ===
695694
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d1547defe34cee6326a61059148afc83228d8ecf
1+
0b3b8a6a354b90fe76a9d82bb34487e5d2f71203

0 commit comments

Comments
 (0)