Skip to content

Commit

Permalink
Test top level fragment inside lazy semantics (#28852)
Browse files Browse the repository at this point in the history
This wasn't clearly articulated and tested why the code structure is
like this but I think the logic is correct - or at least consistent with
the weird semantics.

We place this top-level fragment check inside the recursion so that you
can resolve how many every Lazy or Usable wrappers you want and it still
preserves the same semantics if they weren't there (which they might not
be as a matter of a race condition).

However, we don't actually recurse with the top-level fragment
unwrapping itself because nesting a bunch of keyless fragments isn't the
same as a single fragment/element.

DiffTrain build for commit 4ca20fd.
  • Loading branch information
sebmarkbage committed Apr 17, 2024
1 parent 63dd85f commit bfabc95
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<c83df82d64eddddf249abbe7a211247d>>
* @generated SignedSource<<e3a65ca9b3e1ae4b2d3e0e53482e5985>>
*/

"use strict";
Expand Down Expand Up @@ -7344,14 +7344,17 @@ if (__DEV__) {
lanes,
debugInfo
) {
// This function is not recursive.
// This function is only recursive for Usables/Lazy and not nested arrays.
// That's so that using a Lazy wrapper is unobservable to the Fragment
// convention.
// If the top level item is an array, we treat it as a set of children,
// not as a fragment. Nested arrays on the other hand will be treated as
// fragment nodes. Recursion happens at the normal flow.
// Handle top level unkeyed fragments as if they were arrays.
// This leads to an ambiguity between <>{[...]}</> and <>...</>.
// We treat the ambiguous cases above the same.
// TODO: Let's use recursion like we do for Usable nodes?
// We don't use recursion here because a fragment inside a fragment
// is no longer considered "top level" for these purposes.
var isUnkeyedTopLevelFragment =
typeof newChild === "object" &&
newChild !== null &&
Expand Down Expand Up @@ -26652,7 +26655,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-canary-581264cc";
var ReactVersion = "19.0.0-canary-d96f3fda";

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
657428a9e960cc9c208498be7d2e293007d85cbd
4ca20fd36b2444a74279e7022f89894710b1daab
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<bd640d85592d7d9b873f1a2f979ad51a>>
* @generated SignedSource<<cd896bdd798ca5dd7926d71cf5271eeb>>
*/

"use strict";
Expand Down Expand Up @@ -10799,14 +10799,17 @@ to return true:wantsResponderID| |
lanes,
debugInfo
) {
// This function is not recursive.
// This function is only recursive for Usables/Lazy and not nested arrays.
// That's so that using a Lazy wrapper is unobservable to the Fragment
// convention.
// If the top level item is an array, we treat it as a set of children,
// not as a fragment. Nested arrays on the other hand will be treated as
// fragment nodes. Recursion happens at the normal flow.
// Handle top level unkeyed fragments as if they were arrays.
// This leads to an ambiguity between <>{[...]}</> and <>...</>.
// We treat the ambiguous cases above the same.
// TODO: Let's use recursion like we do for Usable nodes?
// We don't use recursion here because a fragment inside a fragment
// is no longer considered "top level" for these purposes.
var isUnkeyedTopLevelFragment =
typeof newChild === "object" &&
newChild !== null &&
Expand Down Expand Up @@ -30286,7 +30289,7 @@ to return true:wantsResponderID| |
return root;
}

var ReactVersion = "19.0.0-canary-9cace4d2";
var ReactVersion = "19.0.0-canary-273549cb";

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<4c35df7e60d1b43bfa4dd44c80eb34bc>>
* @generated SignedSource<<f5314f257c0eaf16ab8324449affda09>>
*/

"use strict";
Expand Down Expand Up @@ -11070,14 +11070,17 @@ to return true:wantsResponderID| |
lanes,
debugInfo
) {
// This function is not recursive.
// This function is only recursive for Usables/Lazy and not nested arrays.
// That's so that using a Lazy wrapper is unobservable to the Fragment
// convention.
// If the top level item is an array, we treat it as a set of children,
// not as a fragment. Nested arrays on the other hand will be treated as
// fragment nodes. Recursion happens at the normal flow.
// Handle top level unkeyed fragments as if they were arrays.
// This leads to an ambiguity between <>{[...]}</> and <>...</>.
// We treat the ambiguous cases above the same.
// TODO: Let's use recursion like we do for Usable nodes?
// We don't use recursion here because a fragment inside a fragment
// is no longer considered "top level" for these purposes.
var isUnkeyedTopLevelFragment =
typeof newChild === "object" &&
newChild !== null &&
Expand Down Expand Up @@ -30739,7 +30742,7 @@ to return true:wantsResponderID| |
return root;
}

var ReactVersion = "19.0.0-canary-b604e595";
var ReactVersion = "19.0.0-canary-f19a567c";

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down

0 comments on commit bfabc95

Please sign in to comment.