Skip to content

Commit 949350a

Browse files
committed
Refactor DOM Bindings Completely Off of DOMProperty Meta Programming (#26546)
There are four places we have special cases based off the DOMProperty config: 1) DEV-only: ReactDOMUnknownPropertyHook warns for passing booleans to non-boolean attributes. We just need a simple list of all properties that are affected by that. We could probably move this in under setProp instead and have it covered by that list. 2) DEV-only: Hydration. This just needs to read the value from an attribute and compare it to what we'd expect to see if it was rendered on the client. This could use some simplification/unification of the code but I decided to just keep it simple and duplicated since code size isn't an issue. 3) DOMServerFormatConfig pushAttribute: This just maps the special case to how to emit it as a HTML attribute. 4) ReactDOMComponent setProp: This just maps the special case to how to emit it as setAttribute or removeAttribute. Basically we just have to remember to keep pushAttribute and setProp aligned. There's only one long switch in prod per environment. This just turns it all to a giant simple switch statement with string cases. This is in theory the most optimizable since syntactically all the information for a hash table is there. However, unfortunately we know that most VMs don't optimize this very well and instead just turn them into a bunch of ifs. JSC is best. We can minimize the cost by just moving common attribute to the beginning of the list. If we shipped this, maybe VMs will get it together to start optimizing this case but there's a chicken and egg problem here and the game theory reality is that we probably don't want to regress. Therefore, I intend to do a follow up after landing this which reintroduces an object indirection for simple property aliases. That should be enough to make the remaining cases palatable. I'll also extract the most common attributes to the beginning or separate ifs. Ran attribute-behavior fixture and the table is the same. DiffTrain build for commit eeabb73.
1 parent 04d482a commit 949350a

File tree

13 files changed

+19
-19
lines changed

13 files changed

+19
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23884,7 +23884,7 @@ function createFiberRoot(
2388423884
return root;
2388523885
}
2388623886

23887-
var ReactVersion = "18.3.0-next-0ba4d7b0d-20230404";
23887+
var ReactVersion = "18.3.0-next-eeabb7312-20230404";
2388823888

2388923889
// Might add PROFILE later.
2389023890

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8683,7 +8683,7 @@ var devToolsConfig$jscomp$inline_1028 = {
86838683
throw Error("TestRenderer does not support findFiberByHostInstance()");
86848684
},
86858685
bundleType: 0,
8686-
version: "18.3.0-next-0ba4d7b0d-20230404",
8686+
version: "18.3.0-next-eeabb7312-20230404",
86878687
rendererPackageName: "react-test-renderer"
86888688
};
86898689
var internals$jscomp$inline_1220 = {
@@ -8714,7 +8714,7 @@ var internals$jscomp$inline_1220 = {
87148714
scheduleRoot: null,
87158715
setRefreshHandler: null,
87168716
getCurrentFiber: null,
8717-
reconcilerVersion: "18.3.0-next-0ba4d7b0d-20230404"
8717+
reconcilerVersion: "18.3.0-next-eeabb7312-20230404"
87188718
};
87198719
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
87208720
var hook$jscomp$inline_1221 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9108,7 +9108,7 @@ var devToolsConfig$jscomp$inline_1070 = {
91089108
throw Error("TestRenderer does not support findFiberByHostInstance()");
91099109
},
91109110
bundleType: 0,
9111-
version: "18.3.0-next-0ba4d7b0d-20230404",
9111+
version: "18.3.0-next-eeabb7312-20230404",
91129112
rendererPackageName: "react-test-renderer"
91139113
};
91149114
var internals$jscomp$inline_1261 = {
@@ -9139,7 +9139,7 @@ var internals$jscomp$inline_1261 = {
91399139
scheduleRoot: null,
91409140
setRefreshHandler: null,
91419141
getCurrentFiber: null,
9142-
reconcilerVersion: "18.3.0-next-0ba4d7b0d-20230404"
9142+
reconcilerVersion: "18.3.0-next-eeabb7312-20230404"
91439143
};
91449144
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
91459145
var hook$jscomp$inline_1262 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

30-
var ReactVersion = "18.3.0-next-0ba4d7b0d-20230404";
30+
var ReactVersion = "18.3.0-next-eeabb7312-20230404";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,4 +639,4 @@ exports.useSyncExternalStore = function (
639639
);
640640
};
641641
exports.useTransition = useTransition;
642-
exports.version = "18.3.0-next-0ba4d7b0d-20230404";
642+
exports.version = "18.3.0-next-eeabb7312-20230404";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ exports.useSyncExternalStore = function (
642642
);
643643
};
644644
exports.useTransition = useTransition;
645-
exports.version = "18.3.0-next-0ba4d7b0d-20230404";
645+
exports.version = "18.3.0-next-eeabb7312-20230404";
646646

647647
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
648648
if (
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0ba4d7b0d80d942dc8f074f7ce0536e6b2559fbf
1+
eeabb7312f509eb2094452a4389646000ea8ea14

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27177,7 +27177,7 @@ function createFiberRoot(
2717727177
return root;
2717827178
}
2717927179

27180-
var ReactVersion = "18.3.0-next-0ba4d7b0d-20230404";
27180+
var ReactVersion = "18.3.0-next-eeabb7312-20230404";
2718127181

2718227182
function createPortal$1(
2718327183
children,

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9554,7 +9554,7 @@ var roots = new Map(),
95549554
devToolsConfig$jscomp$inline_1052 = {
95559555
findFiberByHostInstance: getInstanceFromNode,
95569556
bundleType: 0,
9557-
version: "18.3.0-next-0ba4d7b0d-20230404",
9557+
version: "18.3.0-next-eeabb7312-20230404",
95589558
rendererPackageName: "react-native-renderer",
95599559
rendererConfig: {
95609560
getInspectorDataForViewTag: function () {
@@ -9596,7 +9596,7 @@ var internals$jscomp$inline_1297 = {
95969596
scheduleRoot: null,
95979597
setRefreshHandler: null,
95989598
getCurrentFiber: null,
9599-
reconcilerVersion: "18.3.0-next-0ba4d7b0d-20230404"
9599+
reconcilerVersion: "18.3.0-next-eeabb7312-20230404"
96009600
};
96019601
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
96029602
var hook$jscomp$inline_1298 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10262,7 +10262,7 @@ var roots = new Map(),
1026210262
devToolsConfig$jscomp$inline_1130 = {
1026310263
findFiberByHostInstance: getInstanceFromNode,
1026410264
bundleType: 0,
10265-
version: "18.3.0-next-0ba4d7b0d-20230404",
10265+
version: "18.3.0-next-eeabb7312-20230404",
1026610266
rendererPackageName: "react-native-renderer",
1026710267
rendererConfig: {
1026810268
getInspectorDataForViewTag: function () {
@@ -10317,7 +10317,7 @@ var roots = new Map(),
1031710317
scheduleRoot: null,
1031810318
setRefreshHandler: null,
1031910319
getCurrentFiber: null,
10320-
reconcilerVersion: "18.3.0-next-0ba4d7b0d-20230404"
10320+
reconcilerVersion: "18.3.0-next-eeabb7312-20230404"
1032110321
});
1032210322
exports.createPortal = function (children, containerTag) {
1032310323
return createPortal$1(

0 commit comments

Comments
 (0)