mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Add tests for ReactNativeAttributePayloadFabric.js (#29608)
## Summary This PR add tests for `ReactNativeAttributePayloadFabric.js`. It introduces `ReactNativeAttributePayloadFabric-test.internal.js`, which is a copy-paste of `ReactNativeAttributePayload-test.internal.js`. On top of that, there is a bunch of new test cases for the `ReactNativeAttributePayloadFabric.create` function. ## How did you test this change? ``` yarn test packages/react-native-renderer ``` DiffTrain build for commit https://github.com/facebook/react/commit/51dd09631ac0c7824fec55f38462846b6fe41d06.
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
38e3b23483bf7a612391cd617a8926aa1f3cf52e
|
||||
51dd09631ac0c7824fec55f38462846b6fe41d06
|
||||
|
||||
+20
-26
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<715c7ff1aa207b21918f50cdc5380bf6>>
|
||||
* @generated SignedSource<<ab8d28628a6daaeaf3d5ca2abe1262e5>>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -2364,17 +2364,23 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
|
||||
}
|
||||
|
||||
function fastAddProperties(payload, props, validAttributes) {
|
||||
var attributeConfig;
|
||||
var prop;
|
||||
// Flatten nested style props.
|
||||
if (isArray(props)) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
payload = fastAddProperties(payload, props[i], validAttributes);
|
||||
}
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
for (var propKey in props) {
|
||||
prop = props[propKey];
|
||||
var prop = props[propKey];
|
||||
|
||||
if (prop === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
attributeConfig = validAttributes[propKey];
|
||||
var attributeConfig = validAttributes[propKey];
|
||||
|
||||
if (attributeConfig == null) {
|
||||
continue;
|
||||
@@ -2392,7 +2398,7 @@ function fastAddProperties(payload, props, validAttributes) {
|
||||
// An atomic prop with custom processing.
|
||||
newValue = attributeConfig.process(prop);
|
||||
} else if (typeof attributeConfig.diff === 'function') {
|
||||
// An atomic prop with custom diffing. We don't do diffing here.
|
||||
// An atomic prop with custom diffing. We don't need to do diffing when adding props.
|
||||
newValue = prop;
|
||||
}
|
||||
|
||||
@@ -2403,18 +2409,7 @@ function fastAddProperties(payload, props, validAttributes) {
|
||||
|
||||
payload[propKey] = newValue;
|
||||
continue;
|
||||
} // Not-atomic prop that needs to be flattened. Likely it's the 'style' prop.
|
||||
// It can be an array.
|
||||
|
||||
|
||||
if (isArray(prop)) {
|
||||
for (var i = 0; i < prop.length; i++) {
|
||||
payload = fastAddProperties(payload, prop[i], attributeConfig);
|
||||
}
|
||||
|
||||
continue;
|
||||
} // Or it can be an object.
|
||||
|
||||
}
|
||||
|
||||
payload = fastAddProperties(payload, prop, attributeConfig);
|
||||
}
|
||||
@@ -2427,11 +2422,7 @@ function fastAddProperties(payload, props, validAttributes) {
|
||||
|
||||
|
||||
function addProperties(updatePayload, props, validAttributes) {
|
||||
if (enableAddPropertiesFastPath) {
|
||||
return fastAddProperties(updatePayload, props, validAttributes);
|
||||
} else {
|
||||
return diffProperties(updatePayload, emptyObject$1, props, validAttributes);
|
||||
}
|
||||
return diffProperties(updatePayload, emptyObject$1, props, validAttributes);
|
||||
}
|
||||
/**
|
||||
* clearProperties clears all the previous props by adding a null sentinel
|
||||
@@ -2445,8 +2436,11 @@ function clearProperties(updatePayload, prevProps, validAttributes) {
|
||||
}
|
||||
|
||||
function create(props, validAttributes) {
|
||||
return addProperties(null, // updatePayload
|
||||
props, validAttributes);
|
||||
if (enableAddPropertiesFastPath) {
|
||||
return fastAddProperties(null, props, validAttributes);
|
||||
} else {
|
||||
return addProperties(null, props, validAttributes);
|
||||
}
|
||||
}
|
||||
function diff(prevProps, nextProps, validAttributes) {
|
||||
return diffProperties(null, // updatePayload
|
||||
@@ -26212,7 +26206,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
|
||||
return root;
|
||||
}
|
||||
|
||||
var ReactVersion = '19.0.0-rc-6b65a277';
|
||||
var ReactVersion = '19.0.0-rc-eb8ea74f';
|
||||
|
||||
/*
|
||||
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
|
||||
|
||||
+37
-40
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<e220fc857a21f1b640cba2d994902482>>
|
||||
* @generated SignedSource<<6a822844da38fad5149fb7f36a73eb44>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -1085,7 +1085,12 @@ function diffNestedProperty(
|
||||
function addNestedProperty(updatePayload, nextProp, validAttributes) {
|
||||
if (!nextProp) return updatePayload;
|
||||
if (!isArrayImpl(nextProp))
|
||||
return addProperties(updatePayload, nextProp, validAttributes);
|
||||
return diffProperties(
|
||||
updatePayload,
|
||||
emptyObject$1,
|
||||
nextProp,
|
||||
validAttributes
|
||||
);
|
||||
for (var i = 0; i < nextProp.length; i++)
|
||||
updatePayload = addNestedProperty(
|
||||
updatePayload,
|
||||
@@ -1196,11 +1201,15 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
|
||||
return updatePayload;
|
||||
}
|
||||
function fastAddProperties(payload, props, validAttributes) {
|
||||
var propKey;
|
||||
for (propKey in props) {
|
||||
var prop = props[propKey];
|
||||
if (isArrayImpl(props)) {
|
||||
for (var i = 0; i < props.length; i++)
|
||||
payload = fastAddProperties(payload, props[i], validAttributes);
|
||||
return payload;
|
||||
}
|
||||
for (i in props) {
|
||||
var prop = props[i];
|
||||
if (void 0 !== prop) {
|
||||
var attributeConfig = validAttributes[propKey];
|
||||
var attributeConfig = validAttributes[i];
|
||||
if (null != attributeConfig) {
|
||||
var newValue = void 0;
|
||||
"function" === typeof prop
|
||||
@@ -1210,25 +1219,18 @@ function fastAddProperties(payload, props, validAttributes) {
|
||||
: "function" === typeof attributeConfig.process
|
||||
? (newValue = attributeConfig.process(prop))
|
||||
: "function" === typeof attributeConfig.diff && (newValue = prop);
|
||||
if (void 0 !== newValue)
|
||||
payload || (payload = {}), (payload[propKey] = newValue);
|
||||
else if (isArrayImpl(prop))
|
||||
for (newValue = 0; newValue < prop.length; newValue++)
|
||||
payload = fastAddProperties(
|
||||
payload,
|
||||
prop[newValue],
|
||||
attributeConfig
|
||||
);
|
||||
else payload = fastAddProperties(payload, prop, attributeConfig);
|
||||
void 0 !== newValue
|
||||
? (payload || (payload = {}), (payload[i] = newValue))
|
||||
: (payload = fastAddProperties(payload, prop, attributeConfig));
|
||||
}
|
||||
}
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
function addProperties(updatePayload, props, validAttributes) {
|
||||
function create(props, validAttributes) {
|
||||
return enableAddPropertiesFastPath
|
||||
? fastAddProperties(updatePayload, props, validAttributes)
|
||||
: diffProperties(updatePayload, emptyObject$1, props, validAttributes);
|
||||
? fastAddProperties(null, props, validAttributes)
|
||||
: diffProperties(null, emptyObject$1, props, validAttributes);
|
||||
}
|
||||
function batchedUpdatesImpl(fn, bookkeeping) {
|
||||
return fn(bookkeeping);
|
||||
@@ -1629,14 +1631,13 @@ function resolveUpdatePriority() {
|
||||
var scheduleTimeout = setTimeout,
|
||||
cancelTimeout = clearTimeout;
|
||||
function cloneHiddenInstance(instance) {
|
||||
var node = instance.node;
|
||||
var JSCompiler_inline_result = addProperties(
|
||||
null,
|
||||
{ style: { display: "none" } },
|
||||
instance.canonical.viewConfig.validAttributes
|
||||
);
|
||||
var node = instance.node,
|
||||
updatePayload = create(
|
||||
{ style: { display: "none" } },
|
||||
instance.canonical.viewConfig.validAttributes
|
||||
);
|
||||
return {
|
||||
node: cloneNodeWithNewProps(node, JSCompiler_inline_result),
|
||||
node: cloneNodeWithNewProps(node, updatePayload),
|
||||
canonical: instance.canonical
|
||||
};
|
||||
}
|
||||
@@ -7321,11 +7322,7 @@ function completeWork(current, workInProgress, renderLanes) {
|
||||
current = nextReactTag;
|
||||
nextReactTag += 2;
|
||||
renderLanes = getViewConfigForType(renderLanes);
|
||||
newChildSet = addProperties(
|
||||
null,
|
||||
newProps,
|
||||
renderLanes.validAttributes
|
||||
);
|
||||
newChildSet = create(newProps, renderLanes.validAttributes);
|
||||
oldProps = createNode(
|
||||
current,
|
||||
renderLanes.uiViewClassName,
|
||||
@@ -10554,7 +10551,7 @@ var roots = new Map(),
|
||||
devToolsConfig$jscomp$inline_1124 = {
|
||||
findFiberByHostInstance: getInstanceFromNode,
|
||||
bundleType: 0,
|
||||
version: "19.0.0-rc-a1153661",
|
||||
version: "19.0.0-rc-d92431d2",
|
||||
rendererPackageName: "react-native-renderer",
|
||||
rendererConfig: {
|
||||
getInspectorDataForInstance: getInspectorDataForInstance,
|
||||
@@ -10570,7 +10567,7 @@ var roots = new Map(),
|
||||
}.bind(null, findNodeHandle)
|
||||
}
|
||||
};
|
||||
var internals$jscomp$inline_1354 = {
|
||||
var internals$jscomp$inline_1350 = {
|
||||
bundleType: devToolsConfig$jscomp$inline_1124.bundleType,
|
||||
version: devToolsConfig$jscomp$inline_1124.version,
|
||||
rendererPackageName: devToolsConfig$jscomp$inline_1124.rendererPackageName,
|
||||
@@ -10597,19 +10594,19 @@ var internals$jscomp$inline_1354 = {
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "19.0.0-rc-a1153661"
|
||||
reconcilerVersion: "19.0.0-rc-d92431d2"
|
||||
};
|
||||
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
var hook$jscomp$inline_1355 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
var hook$jscomp$inline_1351 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
if (
|
||||
!hook$jscomp$inline_1355.isDisabled &&
|
||||
hook$jscomp$inline_1355.supportsFiber
|
||||
!hook$jscomp$inline_1351.isDisabled &&
|
||||
hook$jscomp$inline_1351.supportsFiber
|
||||
)
|
||||
try {
|
||||
(rendererID = hook$jscomp$inline_1355.inject(
|
||||
internals$jscomp$inline_1354
|
||||
(rendererID = hook$jscomp$inline_1351.inject(
|
||||
internals$jscomp$inline_1350
|
||||
)),
|
||||
(injectedHook = hook$jscomp$inline_1355);
|
||||
(injectedHook = hook$jscomp$inline_1351);
|
||||
} catch (err) {}
|
||||
}
|
||||
exports.createPortal = function (children, containerTag) {
|
||||
|
||||
+30
-33
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<2e682bd27fce85dbf44c7d76dad0d567>>
|
||||
* @generated SignedSource<<dc3b2aaa3c81338654d45795eca7bd82>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -1089,7 +1089,12 @@ function diffNestedProperty(
|
||||
function addNestedProperty(updatePayload, nextProp, validAttributes) {
|
||||
if (!nextProp) return updatePayload;
|
||||
if (!isArrayImpl(nextProp))
|
||||
return addProperties(updatePayload, nextProp, validAttributes);
|
||||
return diffProperties(
|
||||
updatePayload,
|
||||
emptyObject$1,
|
||||
nextProp,
|
||||
validAttributes
|
||||
);
|
||||
for (var i = 0; i < nextProp.length; i++)
|
||||
updatePayload = addNestedProperty(
|
||||
updatePayload,
|
||||
@@ -1200,11 +1205,15 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
|
||||
return updatePayload;
|
||||
}
|
||||
function fastAddProperties(payload, props, validAttributes) {
|
||||
var propKey;
|
||||
for (propKey in props) {
|
||||
var prop = props[propKey];
|
||||
if (isArrayImpl(props)) {
|
||||
for (var i = 0; i < props.length; i++)
|
||||
payload = fastAddProperties(payload, props[i], validAttributes);
|
||||
return payload;
|
||||
}
|
||||
for (i in props) {
|
||||
var prop = props[i];
|
||||
if (void 0 !== prop) {
|
||||
var attributeConfig = validAttributes[propKey];
|
||||
var attributeConfig = validAttributes[i];
|
||||
if (null != attributeConfig) {
|
||||
var newValue = void 0;
|
||||
"function" === typeof prop
|
||||
@@ -1214,25 +1223,18 @@ function fastAddProperties(payload, props, validAttributes) {
|
||||
: "function" === typeof attributeConfig.process
|
||||
? (newValue = attributeConfig.process(prop))
|
||||
: "function" === typeof attributeConfig.diff && (newValue = prop);
|
||||
if (void 0 !== newValue)
|
||||
payload || (payload = {}), (payload[propKey] = newValue);
|
||||
else if (isArrayImpl(prop))
|
||||
for (newValue = 0; newValue < prop.length; newValue++)
|
||||
payload = fastAddProperties(
|
||||
payload,
|
||||
prop[newValue],
|
||||
attributeConfig
|
||||
);
|
||||
else payload = fastAddProperties(payload, prop, attributeConfig);
|
||||
void 0 !== newValue
|
||||
? (payload || (payload = {}), (payload[i] = newValue))
|
||||
: (payload = fastAddProperties(payload, prop, attributeConfig));
|
||||
}
|
||||
}
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
function addProperties(updatePayload, props, validAttributes) {
|
||||
function create(props, validAttributes) {
|
||||
return enableAddPropertiesFastPath
|
||||
? fastAddProperties(updatePayload, props, validAttributes)
|
||||
: diffProperties(updatePayload, emptyObject$1, props, validAttributes);
|
||||
? fastAddProperties(null, props, validAttributes)
|
||||
: diffProperties(null, emptyObject$1, props, validAttributes);
|
||||
}
|
||||
function batchedUpdatesImpl(fn, bookkeeping) {
|
||||
return fn(bookkeeping);
|
||||
@@ -1751,14 +1753,13 @@ function resolveUpdatePriority() {
|
||||
var scheduleTimeout = setTimeout,
|
||||
cancelTimeout = clearTimeout;
|
||||
function cloneHiddenInstance(instance) {
|
||||
var node = instance.node;
|
||||
var JSCompiler_inline_result = addProperties(
|
||||
null,
|
||||
{ style: { display: "none" } },
|
||||
instance.canonical.viewConfig.validAttributes
|
||||
);
|
||||
var node = instance.node,
|
||||
updatePayload = create(
|
||||
{ style: { display: "none" } },
|
||||
instance.canonical.viewConfig.validAttributes
|
||||
);
|
||||
return {
|
||||
node: cloneNodeWithNewProps(node, JSCompiler_inline_result),
|
||||
node: cloneNodeWithNewProps(node, updatePayload),
|
||||
canonical: instance.canonical
|
||||
};
|
||||
}
|
||||
@@ -7587,11 +7588,7 @@ function completeWork(current, workInProgress, renderLanes) {
|
||||
current = nextReactTag;
|
||||
nextReactTag += 2;
|
||||
renderLanes = getViewConfigForType(renderLanes);
|
||||
newChildSet = addProperties(
|
||||
null,
|
||||
newProps,
|
||||
renderLanes.validAttributes
|
||||
);
|
||||
newChildSet = create(newProps, renderLanes.validAttributes);
|
||||
oldProps = createNode(
|
||||
current,
|
||||
renderLanes.uiViewClassName,
|
||||
@@ -11260,7 +11257,7 @@ var roots = new Map(),
|
||||
devToolsConfig$jscomp$inline_1205 = {
|
||||
findFiberByHostInstance: getInstanceFromNode,
|
||||
bundleType: 0,
|
||||
version: "19.0.0-rc-cefeada5",
|
||||
version: "19.0.0-rc-ae69ed52",
|
||||
rendererPackageName: "react-native-renderer",
|
||||
rendererConfig: {
|
||||
getInspectorDataForInstance: getInspectorDataForInstance,
|
||||
@@ -11316,7 +11313,7 @@ var roots = new Map(),
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "19.0.0-rc-cefeada5"
|
||||
reconcilerVersion: "19.0.0-rc-ae69ed52"
|
||||
});
|
||||
exports.createPortal = function (children, containerTag) {
|
||||
return createPortal$1(
|
||||
|
||||
Reference in New Issue
Block a user