Add text node support to FragmentInstance operations#35630
Merged
jackpope merged 1 commit intofacebook:mainfrom Jan 28, 2026
Merged
Add text node support to FragmentInstance operations#35630jackpope merged 1 commit intofacebook:mainfrom
jackpope merged 1 commit intofacebook:mainfrom
Conversation
|
Comparing: 87ae75b...1562e56 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show |
d5d0740 to
17dc288
Compare
This was referenced Jan 26, 2026
| return false; | ||
| }); | ||
| if (hasText && !hasElement) { | ||
| console.warn( |
Member
There was a problem hiding this comment.
Shouldn't this be console.error?
| while (i !== (resolvedAlignToTop ? -1 : children.length)) { | ||
| const child = children[i]; | ||
| // For text nodes, use Range API to scroll to their position | ||
| if (enableFragmentRefsTextNodes && child.tag === HostText) { |
Member
There was a problem hiding this comment.
We usually gate with just the flag
if (enableFragmentRefsTextNodes) {
if (child.tag === HostText) {
// ...
}
}
rickhanlonii
approved these changes
Jan 27, 2026
d8d2710 to
d4fbaab
Compare
d4fbaab to
1562e56
Compare
github-actions bot
pushed a commit
that referenced
this pull request
Jan 28, 2026
This PR adds text node support to FragmentInstance operations, allowing fragment refs to properly handle fragments that contain text nodes (either mixed with elements or text-only). Not currently adding/removing new text nodes as we don't need to track them for events or observers in DOM. Will follow up on this and with Fabric support. ## Support through parent element - `dispatchEvent` - `compareDocumentPosition` - `getRootNode` ## Support through Range API - `getClientRects`: Uses Range to calculate bounding rects for text nodes - `scrollIntoView`: Uses Range to scroll to text node positions directly ## No support - `focus`/`focusLast`/`blur`: Noop for text-only fragments - `observeUsing`: Warns for text-only fragments in DEV - `addEventListener`/`removeEventListener`: Ignores text nodes, but still works on Fragment level through `dispatchEvent` DiffTrain build for [875b064](875b064)
github-actions bot
pushed a commit
that referenced
this pull request
Jan 28, 2026
This PR adds text node support to FragmentInstance operations, allowing fragment refs to properly handle fragments that contain text nodes (either mixed with elements or text-only). Not currently adding/removing new text nodes as we don't need to track them for events or observers in DOM. Will follow up on this and with Fabric support. ## Support through parent element - `dispatchEvent` - `compareDocumentPosition` - `getRootNode` ## Support through Range API - `getClientRects`: Uses Range to calculate bounding rects for text nodes - `scrollIntoView`: Uses Range to scroll to text node positions directly ## No support - `focus`/`focusLast`/`blur`: Noop for text-only fragments - `observeUsing`: Warns for text-only fragments in DEV - `addEventListener`/`removeEventListener`: Ignores text nodes, but still works on Fragment level through `dispatchEvent` DiffTrain build for [875b064](875b064)
jackpope
added a commit
that referenced
this pull request
Jan 28, 2026
Stacked on #35630 - Adds test case for compareDocumentPosition, missing before and also extending to text nodes - Adds event handling fixture case for text - Adds getRootNode fixture case for text
jackpope
added a commit
that referenced
this pull request
Feb 11, 2026
Follow up to #35630 We don't currently have any operations that depend on the updating of text nodes added or removed after Fragment mount. But for the sake of completeness and extending the ability to any other host configs, this change calls `commitNewChildToFragmentInstance` and `deleteChildFromFragmentInstance` on HostText fibers. Both DOM and Fabric configs early return because we cannot attach event listeners or observers to text. In the future, there could be some stateful Fragment feature that uses text that could extend this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds text node support to FragmentInstance operations, allowing fragment refs to properly handle fragments that contain text nodes (either mixed with elements or text-only).
Not currently adding/removing new text nodes as we don't need to track them for events or observers in DOM. Will follow up on this and with Fabric support.
Support through parent element
dispatchEventcompareDocumentPositiongetRootNodeSupport through Range API
getClientRects: Uses Range to calculate bounding rects for text nodesscrollIntoView: Uses Range to scroll to text node positions directlyNo support
focus/focusLast/blur: Noop for text-only fragmentsobserveUsing: Warns for text-only fragments in DEVaddEventListener/removeEventListener: Ignores text nodes, but still works on Fragment level throughdispatchEvent