|
9 | 9 | * @oncall react_native
|
10 | 10 | * @fantom_flags enableViewCulling:true
|
11 | 11 | * @fantom_flags enableSynchronousStateUpdates:true
|
| 12 | + * @fantom_flags enableFixForParentTagDuringReparenting:true |
12 | 13 | */
|
13 | 14 |
|
14 | 15 | import 'react-native/Libraries/Core/InitializeCore.js';
|
@@ -1239,3 +1240,78 @@ test('parent-child flattening with culling', () => {
|
1239 | 1240 | 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
|
1240 | 1241 | ]);
|
1241 | 1242 | });
|
| 1243 | + |
| 1244 | +test('parent-child switching from unflattened-flattened to flattened-unflattened', () => { |
| 1245 | + const root = Fantom.createRoot({viewportWidth: 100, viewportHeight: 100}); |
| 1246 | + |
| 1247 | + Fantom.runTask(() => { |
| 1248 | + root.render( |
| 1249 | + <ScrollView |
| 1250 | + style={{height: 100, width: 100}} |
| 1251 | + contentOffset={{x: 0, y: 60}}> |
| 1252 | + <View |
| 1253 | + style={{ |
| 1254 | + marginTop: 100, |
| 1255 | + opacity: 0, |
| 1256 | + }}> |
| 1257 | + <View |
| 1258 | + style={{ |
| 1259 | + marginTop: 50, |
| 1260 | + }}> |
| 1261 | + <View |
| 1262 | + nativeID={'child'} |
| 1263 | + style={{height: 10, width: 10, backgroundColor: 'red'}} |
| 1264 | + /> |
| 1265 | + </View> |
| 1266 | + </View> |
| 1267 | + </ScrollView>, |
| 1268 | + ); |
| 1269 | + }); |
| 1270 | + |
| 1271 | + expect(root.takeMountingManagerLogs()).toEqual([ |
| 1272 | + 'Update {type: "RootView", nativeID: (root)}', |
| 1273 | + 'Create {type: "ScrollView", nativeID: (N/A)}', |
| 1274 | + 'Create {type: "View", nativeID: (N/A)}', |
| 1275 | + 'Create {type: "View", nativeID: (N/A)}', |
| 1276 | + 'Create {type: "View", nativeID: "child"}', |
| 1277 | + 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}', |
| 1278 | + 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: (N/A)}', |
| 1279 | + 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: (N/A)}', |
| 1280 | + 'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}', |
| 1281 | + ]); |
| 1282 | + |
| 1283 | + // force view to be flattened. |
| 1284 | + Fantom.runTask(() => { |
| 1285 | + root.render( |
| 1286 | + <ScrollView |
| 1287 | + style={{height: 100, width: 100}} |
| 1288 | + contentOffset={{x: 0, y: 60}}> |
| 1289 | + <View |
| 1290 | + style={{ |
| 1291 | + marginTop: 100, |
| 1292 | + }}> |
| 1293 | + <View |
| 1294 | + style={{ |
| 1295 | + marginTop: 50, |
| 1296 | + opacity: 0, |
| 1297 | + }}> |
| 1298 | + <View |
| 1299 | + nativeID={'child'} |
| 1300 | + style={{height: 10, width: 10, backgroundColor: 'red'}} |
| 1301 | + /> |
| 1302 | + </View> |
| 1303 | + </View> |
| 1304 | + </ScrollView>, |
| 1305 | + ); |
| 1306 | + }); |
| 1307 | + |
| 1308 | + expect(root.takeMountingManagerLogs()).toEqual([ |
| 1309 | + 'Update {type: "View", nativeID: "child"}', |
| 1310 | + 'Remove {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}', |
| 1311 | + 'Remove {type: "View", parentNativeID: (N/A), index: 0, nativeID: (N/A)}', |
| 1312 | + 'Delete {type: "View", nativeID: (N/A)}', |
| 1313 | + 'Create {type: "View", nativeID: (N/A)}', |
| 1314 | + 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}', |
| 1315 | + 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: (N/A)}', |
| 1316 | + ]); |
| 1317 | +}); |
0 commit comments