Skip to content

Commit 7e80855

Browse files
committed
Fix fastAddProperties to properly nullify style props (#30334)
## Summary This PR fixes the `fastAddProperties` function. Now it nullifies a prop if it was defined in one of the items of a style array, but then set to `undefined` or `null` in one of the subsequent items. E.g. `style: [{top: 0}, {top: undefined}]` should evaluate to `{top: null}`. Also added a test case for that. ## How did you test this change? ``` yarn test packages/react-native-renderer -r=xplat --variant=false yarn test packages/react-native-renderer -r=xplat --variant=true yarn flow native ``` DiffTrain build for commit f510ece.
1 parent 7d4aaba commit 7e80855

14 files changed

+74
-68
lines changed

compiled-rn/VERSION_NATIVE_FB

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.0.0-native-fb-fc1371f6-20240715
1+
19.0.0-native-fb-f510ece8-20240715

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<807d7defa7798acbd559251923830aa0>>
10+
* @generated SignedSource<<76bb9ad89a4d88877387c71561477406>>
1111
*/
1212

1313
"use strict";
@@ -15187,14 +15187,14 @@ __DEV__ &&
1518715187
scheduleRoot: scheduleRoot,
1518815188
setRefreshHandler: setRefreshHandler,
1518915189
getCurrentFiber: getCurrentFiberForDevTools,
15190-
reconcilerVersion: "19.0.0-native-fb-fc1371f6-20240715"
15190+
reconcilerVersion: "19.0.0-native-fb-f510ece8-20240715"
1519115191
});
1519215192
})({
1519315193
findFiberByHostInstance: function () {
1519415194
throw Error("TestRenderer does not support findFiberByHostInstance()");
1519515195
},
1519615196
bundleType: 1,
15197-
version: "19.0.0-native-fb-fc1371f6-20240715",
15197+
version: "19.0.0-native-fb-f510ece8-20240715",
1519815198
rendererPackageName: "react-test-renderer"
1519915199
});
1520015200
exports._Scheduler = Scheduler;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<41bfc6c5964719c61efcaacbfd9ccbe1>>
10+
* @generated SignedSource<<55912220a6d317097bfdce7a18f89b5a>>
1111
*/
1212

1313
"use strict";
@@ -9406,7 +9406,7 @@ var devToolsConfig$jscomp$inline_1034 = {
94069406
throw Error("TestRenderer does not support findFiberByHostInstance()");
94079407
},
94089408
bundleType: 0,
9409-
version: "19.0.0-native-fb-fc1371f6-20240715",
9409+
version: "19.0.0-native-fb-f510ece8-20240715",
94109410
rendererPackageName: "react-test-renderer"
94119411
};
94129412
var internals$jscomp$inline_1223 = {
@@ -9437,7 +9437,7 @@ var internals$jscomp$inline_1223 = {
94379437
scheduleRoot: null,
94389438
setRefreshHandler: null,
94399439
getCurrentFiber: null,
9440-
reconcilerVersion: "19.0.0-native-fb-fc1371f6-20240715"
9440+
reconcilerVersion: "19.0.0-native-fb-f510ece8-20240715"
94419441
};
94429442
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
94439443
var hook$jscomp$inline_1224 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

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

1313
"use strict";
@@ -10026,7 +10026,7 @@ var devToolsConfig$jscomp$inline_1117 = {
1002610026
throw Error("TestRenderer does not support findFiberByHostInstance()");
1002710027
},
1002810028
bundleType: 0,
10029-
version: "19.0.0-native-fb-fc1371f6-20240715",
10029+
version: "19.0.0-native-fb-f510ece8-20240715",
1003010030
rendererPackageName: "react-test-renderer"
1003110031
};
1003210032
(function (internals) {
@@ -10070,7 +10070,7 @@ var devToolsConfig$jscomp$inline_1117 = {
1007010070
scheduleRoot: null,
1007110071
setRefreshHandler: null,
1007210072
getCurrentFiber: null,
10073-
reconcilerVersion: "19.0.0-native-fb-fc1371f6-20240715"
10073+
reconcilerVersion: "19.0.0-native-fb-f510ece8-20240715"
1007410074
});
1007510075
exports._Scheduler = Scheduler;
1007610076
exports.act = act;

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<9e43796dad26b65aef2351c647691b29>>
10+
* @generated SignedSource<<774ee23c4580a270ea6ffd6e54c906bb>>
1111
*/
1212

1313
"use strict";
@@ -1748,7 +1748,7 @@ __DEV__ &&
17481748
exports.useTransition = function () {
17491749
return resolveDispatcher().useTransition();
17501750
};
1751-
exports.version = "19.0.0-native-fb-fc1371f6-20240715";
1751+
exports.version = "19.0.0-native-fb-f510ece8-20240715";
17521752
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
17531753
"function" ===
17541754
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<46ebc18bdae76b802420ba85977104d3>>
10+
* @generated SignedSource<<6d4d7fcf84be677792e205532a36c190>>
1111
*/
1212

1313
"use strict";
@@ -604,4 +604,4 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.0.0-native-fb-fc1371f6-20240715";
607+
exports.version = "19.0.0-native-fb-f510ece8-20240715";

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<a6beab1e2ddc879fd5524db195123a39>>
10+
* @generated SignedSource<<5faabf73666ec4dc0d2fa62bc5fd9940>>
1111
*/
1212

1313
"use strict";
@@ -608,7 +608,7 @@ exports.useSyncExternalStore = function (
608608
exports.useTransition = function () {
609609
return ReactSharedInternals.H.useTransition();
610610
};
611-
exports.version = "19.0.0-native-fb-fc1371f6-20240715";
611+
exports.version = "19.0.0-native-fb-f510ece8-20240715";
612612
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
613613
"function" ===
614614
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fc1371f6bf656821e92c3c41bf65f58686504001
1+
f510ece86d4621d3b0faf9fe59d850f7807dbb16

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

+14-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<c187e11a9478ecae821aa269657417f6>>
10+
* @generated SignedSource<<33b19db231c19a7465cf06a85e551523>>
1111
*/
1212

1313
"use strict";
@@ -1336,22 +1336,24 @@ __DEV__ &&
13361336
return payload;
13371337
}
13381338
for (i in props) {
1339-
var prop = props[i];
1340-
if (void 0 !== prop) {
1341-
var attributeConfig = validAttributes[i];
1342-
if (null != attributeConfig) {
1343-
var newValue = void 0;
1339+
var prop = props[i],
1340+
attributeConfig = validAttributes[i];
1341+
if (null != attributeConfig) {
1342+
var newValue = void 0;
1343+
if (void 0 === prop)
1344+
if (payload && void 0 !== payload[i]) newValue = null;
1345+
else continue;
1346+
else
13441347
"function" === typeof prop
13451348
? (newValue = !0)
13461349
: "object" !== typeof attributeConfig
13471350
? (newValue = prop)
13481351
: "function" === typeof attributeConfig.process
13491352
? (newValue = attributeConfig.process(prop))
13501353
: "function" === typeof attributeConfig.diff && (newValue = prop);
1351-
void 0 !== newValue
1352-
? (payload || (payload = {}), (payload[i] = newValue))
1353-
: (payload = fastAddProperties(payload, prop, attributeConfig));
1354-
}
1354+
void 0 !== newValue
1355+
? (payload || (payload = {}), (payload[i] = newValue))
1356+
: (payload = fastAddProperties(payload, prop, attributeConfig));
13551357
}
13561358
}
13571359
return payload;
@@ -16811,12 +16813,12 @@ __DEV__ &&
1681116813
scheduleRoot: scheduleRoot,
1681216814
setRefreshHandler: setRefreshHandler,
1681316815
getCurrentFiber: getCurrentFiberForDevTools,
16814-
reconcilerVersion: "19.0.0-native-fb-fc1371f6-20240715"
16816+
reconcilerVersion: "19.0.0-native-fb-f510ece8-20240715"
1681516817
});
1681616818
})({
1681716819
findFiberByHostInstance: getInstanceFromNode,
1681816820
bundleType: 1,
16819-
version: "19.0.0-native-fb-fc1371f6-20240715",
16821+
version: "19.0.0-native-fb-f510ece8-20240715",
1682016822
rendererPackageName: "react-native-renderer",
1682116823
rendererConfig: {
1682216824
getInspectorDataForInstance: getInspectorDataForInstance,

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

+14-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<e70e2f329e5ac6a6a2556a1a11ffc8f2>>
10+
* @generated SignedSource<<d389f07884880b4a598ea92a00df86e9>>
1111
*/
1212

1313
"use strict";
@@ -1529,22 +1529,24 @@ function fastAddProperties(payload, props, validAttributes) {
15291529
return payload;
15301530
}
15311531
for (i in props) {
1532-
var prop = props[i];
1533-
if (void 0 !== prop) {
1534-
var attributeConfig = validAttributes[i];
1535-
if (null != attributeConfig) {
1536-
var newValue = void 0;
1532+
var prop = props[i],
1533+
attributeConfig = validAttributes[i];
1534+
if (null != attributeConfig) {
1535+
var newValue = void 0;
1536+
if (void 0 === prop)
1537+
if (payload && void 0 !== payload[i]) newValue = null;
1538+
else continue;
1539+
else
15371540
"function" === typeof prop
15381541
? (newValue = !0)
15391542
: "object" !== typeof attributeConfig
15401543
? (newValue = prop)
15411544
: "function" === typeof attributeConfig.process
15421545
? (newValue = attributeConfig.process(prop))
15431546
: "function" === typeof attributeConfig.diff && (newValue = prop);
1544-
void 0 !== newValue
1545-
? (payload || (payload = {}), (payload[i] = newValue))
1546-
: (payload = fastAddProperties(payload, prop, attributeConfig));
1547-
}
1547+
void 0 !== newValue
1548+
? (payload || (payload = {}), (payload[i] = newValue))
1549+
: (payload = fastAddProperties(payload, prop, attributeConfig));
15481550
}
15491551
}
15501552
return payload;
@@ -10626,7 +10628,7 @@ var roots = new Map(),
1062610628
devToolsConfig$jscomp$inline_1136 = {
1062710629
findFiberByHostInstance: getInstanceFromNode,
1062810630
bundleType: 0,
10629-
version: "19.0.0-native-fb-fc1371f6-20240715",
10631+
version: "19.0.0-native-fb-f510ece8-20240715",
1063010632
rendererPackageName: "react-native-renderer",
1063110633
rendererConfig: {
1063210634
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -10669,7 +10671,7 @@ var internals$jscomp$inline_1362 = {
1066910671
scheduleRoot: null,
1067010672
setRefreshHandler: null,
1067110673
getCurrentFiber: null,
10672-
reconcilerVersion: "19.0.0-native-fb-fc1371f6-20240715"
10674+
reconcilerVersion: "19.0.0-native-fb-f510ece8-20240715"
1067310675
};
1067410676
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1067510677
var hook$jscomp$inline_1363 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

+14-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<d8be9c00f80e631c9664177db73e5c3b>>
10+
* @generated SignedSource<<eaa0badf9f8e7256b11c8a2b348e64fd>>
1111
*/
1212

1313
"use strict";
@@ -1533,22 +1533,24 @@ function fastAddProperties(payload, props, validAttributes) {
15331533
return payload;
15341534
}
15351535
for (i in props) {
1536-
var prop = props[i];
1537-
if (void 0 !== prop) {
1538-
var attributeConfig = validAttributes[i];
1539-
if (null != attributeConfig) {
1540-
var newValue = void 0;
1536+
var prop = props[i],
1537+
attributeConfig = validAttributes[i];
1538+
if (null != attributeConfig) {
1539+
var newValue = void 0;
1540+
if (void 0 === prop)
1541+
if (payload && void 0 !== payload[i]) newValue = null;
1542+
else continue;
1543+
else
15411544
"function" === typeof prop
15421545
? (newValue = !0)
15431546
: "object" !== typeof attributeConfig
15441547
? (newValue = prop)
15451548
: "function" === typeof attributeConfig.process
15461549
? (newValue = attributeConfig.process(prop))
15471550
: "function" === typeof attributeConfig.diff && (newValue = prop);
1548-
void 0 !== newValue
1549-
? (payload || (payload = {}), (payload[i] = newValue))
1550-
: (payload = fastAddProperties(payload, prop, attributeConfig));
1551-
}
1551+
void 0 !== newValue
1552+
? (payload || (payload = {}), (payload[i] = newValue))
1553+
: (payload = fastAddProperties(payload, prop, attributeConfig));
15521554
}
15531555
}
15541556
return payload;
@@ -11336,7 +11338,7 @@ var roots = new Map(),
1133611338
devToolsConfig$jscomp$inline_1217 = {
1133711339
findFiberByHostInstance: getInstanceFromNode,
1133811340
bundleType: 0,
11339-
version: "19.0.0-native-fb-fc1371f6-20240715",
11341+
version: "19.0.0-native-fb-f510ece8-20240715",
1134011342
rendererPackageName: "react-native-renderer",
1134111343
rendererConfig: {
1134211344
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -11392,7 +11394,7 @@ var roots = new Map(),
1139211394
scheduleRoot: null,
1139311395
setRefreshHandler: null,
1139411396
getCurrentFiber: null,
11395-
reconcilerVersion: "19.0.0-native-fb-fc1371f6-20240715"
11397+
reconcilerVersion: "19.0.0-native-fb-f510ece8-20240715"
1139611398
});
1139711399
exports.createPortal = function (children, containerTag) {
1139811400
return createPortal$1(

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

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

1313
"use strict";
@@ -16999,11 +16999,11 @@ __DEV__ &&
1699916999
var emptyObject = {};
1700017000
Object.freeze(emptyObject);
1700117001
var isomorphicReactPackageVersion = React.version;
17002-
if ("19.0.0-native-fb-fc1371f6-20240715" !== isomorphicReactPackageVersion)
17002+
if ("19.0.0-native-fb-f510ece8-20240715" !== isomorphicReactPackageVersion)
1700317003
throw Error(
1700417004
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
1700517005
(isomorphicReactPackageVersion +
17006-
"\n - react-native-renderer: 19.0.0-native-fb-fc1371f6-20240715\nLearn more: https://react.dev/warnings/version-mismatch")
17006+
"\n - react-native-renderer: 19.0.0-native-fb-f510ece8-20240715\nLearn more: https://react.dev/warnings/version-mismatch")
1700717007
);
1700817008
if (
1700917009
"function" !==
@@ -17051,12 +17051,12 @@ __DEV__ &&
1705117051
scheduleRoot: scheduleRoot,
1705217052
setRefreshHandler: setRefreshHandler,
1705317053
getCurrentFiber: getCurrentFiberForDevTools,
17054-
reconcilerVersion: "19.0.0-native-fb-fc1371f6-20240715"
17054+
reconcilerVersion: "19.0.0-native-fb-f510ece8-20240715"
1705517055
});
1705617056
})({
1705717057
findFiberByHostInstance: getInstanceFromTag,
1705817058
bundleType: 1,
17059-
version: "19.0.0-native-fb-fc1371f6-20240715",
17059+
version: "19.0.0-native-fb-f510ece8-20240715",
1706017060
rendererPackageName: "react-native-renderer",
1706117061
rendererConfig: {
1706217062
getInspectorDataForInstance: getInspectorDataForInstance,

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

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

1313
"use strict";
@@ -10780,11 +10780,11 @@ function traverseOwnerTreeUp(hierarchy, instance) {
1078010780
traverseOwnerTreeUp(hierarchy, instance);
1078110781
}
1078210782
var isomorphicReactPackageVersion = React.version;
10783-
if ("19.0.0-native-fb-fc1371f6-20240715" !== isomorphicReactPackageVersion)
10783+
if ("19.0.0-native-fb-f510ece8-20240715" !== isomorphicReactPackageVersion)
1078410784
throw Error(
1078510785
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
1078610786
(isomorphicReactPackageVersion +
10787-
"\n - react-native-renderer: 19.0.0-native-fb-fc1371f6-20240715\nLearn more: https://react.dev/warnings/version-mismatch")
10787+
"\n - react-native-renderer: 19.0.0-native-fb-f510ece8-20240715\nLearn more: https://react.dev/warnings/version-mismatch")
1078810788
);
1078910789
if (
1079010790
"function" !==
@@ -10834,7 +10834,7 @@ var roots = new Map(),
1083410834
devToolsConfig$jscomp$inline_1210 = {
1083510835
findFiberByHostInstance: getInstanceFromTag,
1083610836
bundleType: 0,
10837-
version: "19.0.0-native-fb-fc1371f6-20240715",
10837+
version: "19.0.0-native-fb-f510ece8-20240715",
1083810838
rendererPackageName: "react-native-renderer",
1083910839
rendererConfig: {
1084010840
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -10877,7 +10877,7 @@ var internals$jscomp$inline_1457 = {
1087710877
scheduleRoot: null,
1087810878
setRefreshHandler: null,
1087910879
getCurrentFiber: null,
10880-
reconcilerVersion: "19.0.0-native-fb-fc1371f6-20240715"
10880+
reconcilerVersion: "19.0.0-native-fb-f510ece8-20240715"
1088110881
};
1088210882
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1088310883
var hook$jscomp$inline_1458 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

0 commit comments

Comments
 (0)