Skip to content

[DOM] Scope Fragment once listeners to the fragment, not each child - #37169

Merged
jackpope merged 1 commit into
mainfrom
fragment-refs/once-listener-fragment-scope
Aug 13, 2026
Merged

[DOM] Scope Fragment once listeners to the fragment, not each child#37169
jackpope merged 1 commit into
mainfrom
fragment-refs/once-listener-fragment-scope

Conversation

@jackpope

@jackpope jackpope commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

{once: true} events are supposed to fire once. Since the addEventListener implementation adds a listener to each host child, once was not respected if you trigger event on multiple children.

Here we wrap the event so we can remove is after the first call

@meta-cla meta-cla Bot added the CLA Signed label Jul 31, 2026
@jackpope
jackpope force-pushed the fragment-refs/once-listener-fragment-scope branch from 9ca01df to e22b430 Compare July 31, 2026 19:15
@github-actions github-actions Bot added the React Core Team Opened by a member of the React Core Team label Jul 31, 2026
@jackpope
jackpope force-pushed the fragment-refs/once-listener-fragment-scope branch from e22b430 to ac73de1 Compare July 31, 2026 20:15
@jackpope
jackpope force-pushed the fragment-refs/once-listener-fragment-scope branch 2 times, most recently from c3dbf25 to 793529c Compare July 31, 2026 21:05
@jackpope
jackpope marked this pull request as ready for review July 31, 2026 21:12
@jackpope
jackpope requested a review from eps1lon July 31, 2026 21:12
}
case HostHoistable:
case HostComponent: {
// TODO: Enable HostText for RN

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

intentional? Probably worth mentioning why.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ah yes, this was left over stale comment

@jackpope
jackpope force-pushed the fragment-refs/once-listener-fragment-scope branch from 793529c to dcf4360 Compare August 9, 2026 19:15
@jackpope
jackpope force-pushed the fragment-refs/once-listener-fragment-scope branch from dcf4360 to 881c61e Compare August 11, 2026 03:49

@poteto poteto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM (light skim). Stacking stamps for the fragment-refs land sequence.

@jackpope
jackpope force-pushed the fragment-refs/once-listener-fragment-scope branch from 881c61e to bcbcd2a Compare August 12, 2026 01:57
Base automatically changed from fragment-refs/text-child-deletion-effects to main August 13, 2026 03:17
{once: true} was forwarded to every host child, so each child could fire
independently and newly inserted children re-armed the listener from
_eventListeners. Wrap once listeners so the first fire removes them from
the fragment and all children.

Also, removes dead comment about HostText in RN.
@jackpope
jackpope force-pushed the fragment-refs/once-listener-fragment-scope branch from bcbcd2a to 8e9091c Compare August 13, 2026 03:17
@react-sizebot

Copy link
Copy Markdown

Comparing: 9880384...8e9091c

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 = 7.35 kB 7.35 kB = 1.96 kB 1.96 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.18% 620.78 kB 621.88 kB +0.25% 109.71 kB 109.98 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 7.36 kB 7.36 kB = 1.97 kB 1.96 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.16% 691.99 kB 693.09 kB +0.18% 121.21 kB 121.43 kB
facebook-www/ReactDOM-prod.classic.js +0.15% 712.34 kB 713.44 kB +0.19% 124.70 kB 124.93 kB
facebook-www/ReactDOM-prod.modern.js +0.16% 702.65 kB 703.76 kB +0.19% 123.12 kB 123.35 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 8e9091c

@jackpope
jackpope merged commit beef6d6 into main Aug 13, 2026
238 checks passed
github-actions Bot pushed a commit that referenced this pull request Aug 13, 2026
…37169)

`{once: true}` events are supposed to fire once. Since the
`addEventListener` implementation adds a listener to each host child,
`once` was not respected if you trigger event on multiple children.

Here we wrap the event so we can remove is after the first call

DiffTrain build for [beef6d6](beef6d6)
github-actions Bot pushed a commit that referenced this pull request Aug 13, 2026
…37169)

`{once: true}` events are supposed to fire once. Since the
`addEventListener` implementation adds a listener to each host child,
`once` was not respected if you trigger event on multiple children.

Here we wrap the event so we can remove is after the first call

DiffTrain build for [beef6d6](beef6d6)
github-actions Bot pushed a commit to code/lib-react that referenced this pull request Aug 14, 2026
…eact#37169)

`{once: true}` events are supposed to fire once. Since the
`addEventListener` implementation adds a listener to each host child,
`once` was not respected if you trigger event on multiple children.

Here we wrap the event so we can remove is after the first call

DiffTrain build for [beef6d6](react@beef6d6)
github-actions Bot pushed a commit to code/lib-react that referenced this pull request Aug 14, 2026
…eact#37169)

`{once: true}` events are supposed to fire once. Since the
`addEventListener` implementation adds a listener to each host child,
`once` was not respected if you trigger event on multiple children.

Here we wrap the event so we can remove is after the first call

DiffTrain build for [beef6d6](react@beef6d6)
github-actions Bot pushed a commit to xb18/react that referenced this pull request Aug 14, 2026
…eact#37169)

`{once: true}` events are supposed to fire once. Since the
`addEventListener` implementation adds a listener to each host child,
`once` was not respected if you trigger event on multiple children.

Here we wrap the event so we can remove is after the first call

DiffTrain build for [beef6d6](react@beef6d6)
github-actions Bot pushed a commit to xb18/react that referenced this pull request Aug 14, 2026
…eact#37169)

`{once: true}` events are supposed to fire once. Since the
`addEventListener` implementation adds a listener to each host child,
`once` was not respected if you trigger event on multiple children.

Here we wrap the event so we can remove is after the first call

DiffTrain build for [beef6d6](react@beef6d6)
github-actions Bot pushed a commit to HaroldHuanrongLIU/react that referenced this pull request Aug 14, 2026
…eact#37169)

`{once: true}` events are supposed to fire once. Since the
`addEventListener` implementation adds a listener to each host child,
`once` was not respected if you trigger event on multiple children.

Here we wrap the event so we can remove is after the first call

DiffTrain build for [beef6d6](react@beef6d6)
github-actions Bot pushed a commit to HaroldHuanrongLIU/react that referenced this pull request Aug 14, 2026
…eact#37169)

`{once: true}` events are supposed to fire once. Since the
`addEventListener` implementation adds a listener to each host child,
`once` was not respected if you trigger event on multiple children.

Here we wrap the event so we can remove is after the first call

DiffTrain build for [beef6d6](react@beef6d6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants