Skip to content

Commit 571a247

Browse files
committed
jsx(): Inline reserved prop checks (#28262)
The JSX runtime (both the new one and the classic createElement runtime) check for reserved props like `key` and `ref` by doing a lookup in a plain object map with `hasOwnProperty`. There are only a few reserved props so this inlines the checks instead. DiffTrain build for commit 1beb941.
1 parent ef80012 commit 571a247

File tree

11 files changed

+79
-70
lines changed

11 files changed

+79
-70
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25725,7 +25725,7 @@ if (__DEV__) {
2572525725
return root;
2572625726
}
2572725727

25728-
var ReactVersion = "18.3.0-canary-0d11563b4-20240206";
25728+
var ReactVersion = "18.3.0-canary-1beb94133-20240206";
2572925729

2573025730
// Might add PROFILE later.
2573125731

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9157,7 +9157,7 @@ var devToolsConfig$jscomp$inline_1012 = {
91579157
throw Error("TestRenderer does not support findFiberByHostInstance()");
91589158
},
91599159
bundleType: 0,
9160-
version: "18.3.0-canary-0d11563b4-20240206",
9160+
version: "18.3.0-canary-1beb94133-20240206",
91619161
rendererPackageName: "react-test-renderer"
91629162
};
91639163
var internals$jscomp$inline_1190 = {
@@ -9188,7 +9188,7 @@ var internals$jscomp$inline_1190 = {
91889188
scheduleRoot: null,
91899189
setRefreshHandler: null,
91909190
getCurrentFiber: null,
9191-
reconcilerVersion: "18.3.0-canary-0d11563b4-20240206"
9191+
reconcilerVersion: "18.3.0-canary-1beb94133-20240206"
91929192
};
91939193
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
91949194
var hook$jscomp$inline_1191 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9585,7 +9585,7 @@ var devToolsConfig$jscomp$inline_1054 = {
95859585
throw Error("TestRenderer does not support findFiberByHostInstance()");
95869586
},
95879587
bundleType: 0,
9588-
version: "18.3.0-canary-0d11563b4-20240206",
9588+
version: "18.3.0-canary-1beb94133-20240206",
95899589
rendererPackageName: "react-test-renderer"
95909590
};
95919591
var internals$jscomp$inline_1231 = {
@@ -9616,7 +9616,7 @@ var internals$jscomp$inline_1231 = {
96169616
scheduleRoot: null,
96179617
setRefreshHandler: null,
96189618
getCurrentFiber: null,
9619-
reconcilerVersion: "18.3.0-canary-0d11563b4-20240206"
9619+
reconcilerVersion: "18.3.0-canary-1beb94133-20240206"
96209620
};
96219621
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
96229622
var hook$jscomp$inline_1232 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

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

1313
"use strict";
@@ -563,12 +563,6 @@ if (__DEV__) {
563563
}
564564

565565
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
566-
var RESERVED_PROPS = {
567-
key: true,
568-
ref: true,
569-
__self: true,
570-
__source: true
571-
};
572566
var specialPropKeyWarningShown;
573567
var specialPropRefWarningShown;
574568
var didWarnAboutStringRefs;
@@ -799,8 +793,11 @@ if (__DEV__) {
799793

800794
for (propName in config) {
801795
if (
802-
hasOwnProperty.call(config, propName) &&
803-
!RESERVED_PROPS.hasOwnProperty(propName)
796+
hasOwnProperty.call(config, propName) && // Skip over reserved prop names
797+
propName !== "key" && // TODO: These will no longer be reserved in the next major
798+
propName !== "ref" &&
799+
propName !== "__self" &&
800+
propName !== "__source"
804801
) {
805802
props[propName] = config[propName];
806803
}

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

+6-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<8fbe3bc0848b0909865f9804f5adcef7>>
10+
* @generated SignedSource<<4e6cfb0b86828f5be0c6c8e34f4fdb7a>>
1111
*/
1212

1313
"use strict";
@@ -563,12 +563,6 @@ if (__DEV__) {
563563
}
564564

565565
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
566-
var RESERVED_PROPS = {
567-
key: true,
568-
ref: true,
569-
__self: true,
570-
__source: true
571-
};
572566
var specialPropKeyWarningShown;
573567
var specialPropRefWarningShown;
574568
var didWarnAboutStringRefs;
@@ -799,8 +793,11 @@ if (__DEV__) {
799793

800794
for (propName in config) {
801795
if (
802-
hasOwnProperty.call(config, propName) &&
803-
!RESERVED_PROPS.hasOwnProperty(propName)
796+
hasOwnProperty.call(config, propName) && // Skip over reserved prop names
797+
propName !== "key" && // TODO: These will no longer be reserved in the next major
798+
propName !== "ref" &&
799+
propName !== "__self" &&
800+
propName !== "__source"
804801
) {
805802
props[propName] = config[propName];
806803
}

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<82444ded84168f50c5e2d5115e52dac9>>
10+
* @generated SignedSource<<d95535f2595d28064d67106ad7fa3c58>>
1111
*/
1212

1313
"use strict";
@@ -16,8 +16,7 @@ var React = require("react"),
1616
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
1717
hasOwnProperty = Object.prototype.hasOwnProperty,
1818
ReactCurrentOwner =
19-
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
20-
RESERVED_PROPS = { key: !0, ref: !0, __self: !0, __source: !0 };
19+
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;
2120
function jsx$1(type, config, maybeKey) {
2221
var propName,
2322
props = {},
@@ -28,7 +27,10 @@ function jsx$1(type, config, maybeKey) {
2827
void 0 !== config.ref && (ref = config.ref);
2928
for (propName in config)
3029
hasOwnProperty.call(config, propName) &&
31-
!RESERVED_PROPS.hasOwnProperty(propName) &&
30+
"key" !== propName &&
31+
"ref" !== propName &&
32+
"__self" !== propName &&
33+
"__source" !== propName &&
3234
(props[propName] = config[propName]);
3335
if (type && type.defaultProps)
3436
for (propName in ((config = type.defaultProps), config))

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<82444ded84168f50c5e2d5115e52dac9>>
10+
* @generated SignedSource<<d95535f2595d28064d67106ad7fa3c58>>
1111
*/
1212

1313
"use strict";
@@ -16,8 +16,7 @@ var React = require("react"),
1616
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
1717
hasOwnProperty = Object.prototype.hasOwnProperty,
1818
ReactCurrentOwner =
19-
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
20-
RESERVED_PROPS = { key: !0, ref: !0, __self: !0, __source: !0 };
19+
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;
2120
function jsx$1(type, config, maybeKey) {
2221
var propName,
2322
props = {},
@@ -28,7 +27,10 @@ function jsx$1(type, config, maybeKey) {
2827
void 0 !== config.ref && (ref = config.ref);
2928
for (propName in config)
3029
hasOwnProperty.call(config, propName) &&
31-
!RESERVED_PROPS.hasOwnProperty(propName) &&
30+
"key" !== propName &&
31+
"ref" !== propName &&
32+
"__self" !== propName &&
33+
"__source" !== propName &&
3234
(props[propName] = config[propName]);
3335
if (type && type.defaultProps)
3436
for (propName in ((config = type.defaultProps), config))

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

+17-20
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<8d63d863a541aceb06d589df679b4dc2>>
10+
* @generated SignedSource<<593daac7ac70a57cfd731bbfdac659fc>>
1111
*/
1212

1313
"use strict";
@@ -24,7 +24,7 @@ if (__DEV__) {
2424
) {
2525
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2626
}
27-
var ReactVersion = "18.3.0-canary-0d11563b4-20240206";
27+
var ReactVersion = "18.3.0-canary-1beb94133-20240206";
2828

2929
// ATTENTION
3030
// When adding new symbols to this file,
@@ -679,12 +679,6 @@ if (__DEV__) {
679679
// $FlowFixMe[method-unbinding]
680680
var hasOwnProperty = Object.prototype.hasOwnProperty;
681681

682-
var RESERVED_PROPS$1 = {
683-
key: true,
684-
ref: true,
685-
__self: true,
686-
__source: true
687-
};
688682
var specialPropKeyWarningShown$1,
689683
specialPropRefWarningShown$1,
690684
didWarnAboutStringRefs$1;
@@ -908,8 +902,11 @@ if (__DEV__) {
908902

909903
for (propName in config) {
910904
if (
911-
hasOwnProperty.call(config, propName) &&
912-
!RESERVED_PROPS$1.hasOwnProperty(propName)
905+
hasOwnProperty.call(config, propName) && // Skip over reserved prop names
906+
propName !== "key" && // TODO: These will no longer be reserved in the next major
907+
propName !== "ref" &&
908+
propName !== "__self" &&
909+
propName !== "__source"
913910
) {
914911
props[propName] = config[propName];
915912
}
@@ -1038,8 +1035,11 @@ if (__DEV__) {
10381035

10391036
for (propName in config) {
10401037
if (
1041-
hasOwnProperty.call(config, propName) &&
1042-
!RESERVED_PROPS$1.hasOwnProperty(propName)
1038+
hasOwnProperty.call(config, propName) && // Skip over reserved prop names
1039+
propName !== "key" && // TODO: These will no longer be reserved in the next major
1040+
propName !== "ref" &&
1041+
propName !== "__self" &&
1042+
propName !== "__source"
10431043
) {
10441044
if (config[propName] === undefined && defaultProps !== undefined) {
10451045
// Resolve default props
@@ -1352,12 +1352,6 @@ if (__DEV__) {
13521352
}
13531353

13541354
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
1355-
var RESERVED_PROPS = {
1356-
key: true,
1357-
ref: true,
1358-
__self: true,
1359-
__source: true
1360-
};
13611355
var specialPropKeyWarningShown;
13621356
var specialPropRefWarningShown;
13631357
var didWarnAboutStringRefs;
@@ -1588,8 +1582,11 @@ if (__DEV__) {
15881582

15891583
for (propName in config) {
15901584
if (
1591-
hasOwnProperty.call(config, propName) &&
1592-
!RESERVED_PROPS.hasOwnProperty(propName)
1585+
hasOwnProperty.call(config, propName) && // Skip over reserved prop names
1586+
propName !== "key" && // TODO: These will no longer be reserved in the next major
1587+
propName !== "ref" &&
1588+
propName !== "__self" &&
1589+
propName !== "__source"
15931590
) {
15941591
props[propName] = config[propName];
15951592
}

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

+16-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<488ba8e30fbf06899d70dafff11452dc>>
10+
* @generated SignedSource<<ba8018b7d9a5dbed3051133347c5987d>>
1111
*/
1212

1313
"use strict";
@@ -82,8 +82,7 @@ assign(pureComponentPrototype, Component.prototype);
8282
pureComponentPrototype.isPureReactComponent = !0;
8383
var isArrayImpl = Array.isArray,
8484
hasOwnProperty = Object.prototype.hasOwnProperty,
85-
ReactCurrentOwner$1 = { current: null },
86-
RESERVED_PROPS$1 = { key: !0, ref: !0, __self: !0, __source: !0 };
85+
ReactCurrentOwner$1 = { current: null };
8786
function createElement$1(type, config, children) {
8887
var propName,
8988
props = {},
@@ -94,7 +93,10 @@ function createElement$1(type, config, children) {
9493
void 0 !== config.key && (key = "" + config.key),
9594
config))
9695
hasOwnProperty.call(config, propName) &&
97-
!RESERVED_PROPS$1.hasOwnProperty(propName) &&
96+
"key" !== propName &&
97+
"ref" !== propName &&
98+
"__self" !== propName &&
99+
"__source" !== propName &&
98100
(props[propName] = config[propName]);
99101
var childrenLength = arguments.length - 2;
100102
if (1 === childrenLength) props.children = children;
@@ -142,8 +144,7 @@ var ReactCurrentDispatcher = { current: null },
142144
ReactCurrentBatchConfig: ReactCurrentBatchConfig,
143145
ReactCurrentOwner: ReactCurrentOwner$1
144146
},
145-
ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner,
146-
RESERVED_PROPS = { key: !0, ref: !0, __self: !0, __source: !0 };
147+
ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
147148
function jsx$1(type, config, maybeKey) {
148149
var propName,
149150
props = {},
@@ -154,7 +155,10 @@ function jsx$1(type, config, maybeKey) {
154155
void 0 !== config.ref && (ref = config.ref);
155156
for (propName in config)
156157
hasOwnProperty.call(config, propName) &&
157-
!RESERVED_PROPS.hasOwnProperty(propName) &&
158+
"key" !== propName &&
159+
"ref" !== propName &&
160+
"__self" !== propName &&
161+
"__source" !== propName &&
158162
(props[propName] = config[propName]);
159163
if (type && type.defaultProps)
160164
for (propName in ((config = type.defaultProps), config))
@@ -377,7 +381,10 @@ exports.cloneElement = function (element, config, children) {
377381
var defaultProps = element.type.defaultProps;
378382
for (propName in config)
379383
hasOwnProperty.call(config, propName) &&
380-
!RESERVED_PROPS$1.hasOwnProperty(propName) &&
384+
"key" !== propName &&
385+
"ref" !== propName &&
386+
"__self" !== propName &&
387+
"__source" !== propName &&
381388
(props[propName] =
382389
void 0 === config[propName] && void 0 !== defaultProps
383390
? defaultProps[propName]
@@ -543,4 +550,4 @@ exports.useSyncExternalStore = function (
543550
exports.useTransition = function () {
544551
return ReactCurrentDispatcher.current.useTransition();
545552
};
546-
exports.version = "18.3.0-canary-0d11563b4-20240206";
553+
exports.version = "18.3.0-canary-1beb94133-20240206";

0 commit comments

Comments
 (0)