Skip to content

[DOM] Register error event when hydrating <embed> - #37403

Open
harjothkhara wants to merge 1 commit into
react:mainfrom
harjothkhara:oss-find/react-2026-08-28
Open

[DOM] Register error event when hydrating <embed>#37403
harjothkhara wants to merge 1 commit into
react:mainfrom
harjothkhara:oss-find/react-2026-08-28

Conversation

@harjothkhara

Copy link
Copy Markdown

Summary

onError on a hydrated <embed> never fires. The same element rendered with createRoot fires it, and onLoad works in both modes.

Root cause

error and load don't bubble, so React only receives them through a per-element listenToNonDelegatedEvent call. #26501 made setInitialProperties register both error and load for <embed> (grouped with source/link, ReactDOMComponent.js:1417), but hydrateProperties still had the pre-#26501 grouping with iframe/object, which registers only load (ReactDOMComponent.js:3168). So a hydrated <embed> has no error listener and onError (and any ancestor's emulated-bubble onError) never dispatches.

Fix

Move case 'embed' in hydrateProperties into the group that registers both error and load, matching the mount path.

Not changed here: the mount path also registers load for <source> while hydration registers only error. That difference dates to the same refactor; it can be aligned the same way if desired, but it's a separate surface so I left it out of this diff.

How did you test this change?

Added a test that server-renders an <embed> with onLoad/onError, hydrates it, and dispatches both events. On main it fails:

expect(handleError).toHaveBeenCalledTimes(1)
Expected number of calls: 1
Received number of calls: 0

With the fix it passes. Also ran:

  • yarn test packages/react-dom/src/__tests__/ReactDOMEventListener-test.js — 24 passed (also with --prod and --release-channel=www-classic)
  • yarn test on ReactDOMEventPropagation, ReactServerRenderingHydration, ReactDOMHydrationDiff, ReactBrowserEventEmitter, ReactDOMServerIntegrationElements, ReactDOMServerPartialHydration — all passing except one pre-existing [GATED, SHOULD FAIL] failure in ReactDOMServerPartialHydration that reproduces identically on main
  • yarn flow dom-node, yarn linc, yarn prettier-check — clean

setInitialProperties registers both error and load non-delegated
listeners for <embed>, but hydrateProperties grouped embed with
iframe/object and only registered load. As a result onError on a
hydrated <embed> never fired, while a client-rendered one worked.

Move embed to the error+load group in hydrateProperties to match
the mount path, and add a hydration regression test.
@meta-cla meta-cla Bot added the CLA Signed label Aug 28, 2026
@github-actions

Copy link
Copy Markdown

A size report will appear here when the build finishes.

Generated by sizebot against 3dda1b1

@harjothkhara
harjothkhara marked this pull request as ready for review August 28, 2026 16:48
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.

1 participant