Skip to content

Commit dc6a835

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 [eeabb73](eeabb73)
1 parent 5b5baac commit dc6a835

25 files changed

+17313
-9097
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
da94e8b24a3f31a3e805f9bf6bba73055aad9d41
1+
eeabb7312f509eb2094452a4389646000ea8ea14

compiled/facebook-www/React-dev.modern.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-www-modern-c754d90a";
30+
var ReactVersion = "18.3.0-www-modern-a911b5ee";
3131

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

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
6969
return self;
7070
}
7171

72-
var ReactVersion = "18.3.0-www-classic-828157c0";
72+
var ReactVersion = "18.3.0-www-classic-1e3ad805";
7373

7474
var LegacyRoot = 0;
7575
var ConcurrentRoot = 1;

compiled/facebook-www/ReactART-prod.modern.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9732,7 +9732,7 @@ var slice = Array.prototype.slice,
97329732
return null;
97339733
},
97349734
bundleType: 0,
9735-
version: "18.3.0-www-modern-bf67bce4",
9735+
version: "18.3.0-www-modern-3993aa7c",
97369736
rendererPackageName: "react-art"
97379737
};
97389738
var internals$jscomp$inline_1324 = {
@@ -9763,7 +9763,7 @@ var internals$jscomp$inline_1324 = {
97639763
scheduleRoot: null,
97649764
setRefreshHandler: null,
97659765
getCurrentFiber: null,
9766-
reconcilerVersion: "18.3.0-www-modern-bf67bce4"
9766+
reconcilerVersion: "18.3.0-www-modern-3993aa7c"
97679767
};
97689768
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
97699769
var hook$jscomp$inline_1325 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

0 commit comments

Comments
 (0)