Skip to content

Conversation

@jackpope
Copy link
Contributor

@jackpope jackpope commented Jan 26, 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

@meta-cla meta-cla bot added the CLA Signed label Jan 26, 2026
@react-sizebot
Copy link

react-sizebot commented Jan 26, 2026

Comparing: 3e319a9...17dc288

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.15% 608.67 kB 609.58 kB +0.16% 107.63 kB 107.80 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.14% 674.60 kB 675.51 kB +0.15% 118.58 kB 118.75 kB
facebook-www/ReactDOM-prod.classic.js +0.18% 693.92 kB 695.14 kB +0.18% 121.98 kB 122.19 kB
facebook-www/ReactDOM-prod.modern.js +0.18% 684.31 kB 685.52 kB +0.18% 120.37 kB 120.59 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-reconciler/cjs/react-reconciler-reflection.production.js +0.29% 11.29 kB 11.32 kB +0.38% 2.63 kB 2.64 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler-reflection.production.js +0.29% 11.29 kB 11.32 kB +0.38% 2.63 kB 2.64 kB
oss-stable/react-reconciler/cjs/react-reconciler-reflection.production.js +0.29% 11.29 kB 11.32 kB +0.38% 2.63 kB 2.64 kB
oss-experimental/react-reconciler/cjs/react-reconciler-reflection.development.js +0.29% 12.75 kB 12.79 kB +0.26% 2.71 kB 2.72 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler-reflection.development.js +0.29% 12.75 kB 12.79 kB +0.26% 2.71 kB 2.72 kB
oss-stable/react-reconciler/cjs/react-reconciler-reflection.development.js +0.29% 12.75 kB 12.79 kB +0.26% 2.71 kB 2.72 kB
facebook-react-native/react-dom/cjs/ReactDOMClient-prod.js +0.20% 595.71 kB 596.93 kB +0.22% 104.80 kB 105.03 kB
facebook-react-native/react-dom/cjs/ReactDOMProfiling-prod.js +0.20% 601.37 kB 602.59 kB +0.21% 105.94 kB 106.16 kB

Generated by 🚫 dangerJS against 17dc288

return false;
});
if (hasText && !hasElement) {
console.warn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Member

@rickhanlonii rickhanlonii Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually gate with just the flag

if (enableFragmentRefsTextNodes) {
  if (child.tag === HostText) {
    // ...
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants