diff --git a/packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js b/packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js index 5fa920a13f0fa..59c2920778008 100644 --- a/packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js +++ b/packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js @@ -537,7 +537,8 @@ export function retryIfBlockedOn( if (enableFormActions) { // Check the document if there are any queued form actions. - const root = unblocked === document ? unblocked : unblocked.ownerDocument; + // If there's no ownerDocument, then this is the document. + const root = unblocked.ownerDocument || unblocked; const formReplayingQueue: void | FormReplayingQueue = (root: any) .$$reactFormReplay; if (formReplayingQueue != null) { diff --git a/packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetShared.js b/packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetShared.js index 73d1ccfd8ce4b..89f6c3cafe7ed 100644 --- a/packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetShared.js +++ b/packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetShared.js @@ -196,7 +196,8 @@ export function listenToFormSubmissionsForReplaying() { // javascript: URL placeholder value. So we might not be the first to declare it. // We attach it to the form's root node, which is the shared environment context // where we preserve sequencing and where we'll pick it up from during hydration. - const root = form === document ? form : form.ownerDocument; + // If there's no ownerDocument, then this is the document. + const root = form.ownerDocument || form; (root['$$reactFormReplay'] = root['$$reactFormReplay'] || []).push( form, submitter,