[DOM] Register error event when hydrating <embed> - #37403
Open
harjothkhara wants to merge 1 commit into
Open
Conversation
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.
harjothkhara
marked this pull request as ready for review
August 28, 2026 16:48
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.
Summary
onErroron a hydrated<embed>never fires. The same element rendered withcreateRootfires it, andonLoadworks in both modes.Root cause
errorandloaddon't bubble, so React only receives them through a per-elementlistenToNonDelegatedEventcall. #26501 madesetInitialPropertiesregister botherrorandloadfor<embed>(grouped withsource/link,ReactDOMComponent.js:1417), buthydratePropertiesstill had the pre-#26501 grouping withiframe/object, which registers onlyload(ReactDOMComponent.js:3168). So a hydrated<embed>has noerrorlistener andonError(and any ancestor's emulated-bubbleonError) never dispatches.Fix
Move
case 'embed'inhydratePropertiesinto the group that registers botherrorandload, matching the mount path.Not changed here: the mount path also registers
loadfor<source>while hydration registers onlyerror. 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>withonLoad/onError, hydrates it, and dispatches both events. Onmainit fails:With the fix it passes. Also ran:
yarn test packages/react-dom/src/__tests__/ReactDOMEventListener-test.js— 24 passed (also with--prodand--release-channel=www-classic)yarn teston ReactDOMEventPropagation, ReactServerRenderingHydration, ReactDOMHydrationDiff, ReactBrowserEventEmitter, ReactDOMServerIntegrationElements, ReactDOMServerPartialHydration — all passing except one pre-existing[GATED, SHOULD FAIL]failure in ReactDOMServerPartialHydration that reproduces identically onmainyarn flow dom-node,yarn linc,yarn prettier-check— clean