Skip to content

Commit 9c987a3

Browse files
rickhanloniiAndyPengc12
authored andcommitted
s/getRootNode/ownerDocument (facebook#28412)
getRootNode isn't always available, use ownerDocument instead
1 parent 58c3f5b commit 9c987a3

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

packages/react-dom-bindings/src/client/ReactDOMComponent.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2273,7 +2273,7 @@ function diffHydratedCustomComponent(
22732273
// as a shared module for that reason.
22742274
const EXPECTED_FORM_ACTION_URL =
22752275
// eslint-disable-next-line no-script-url
2276-
"javascript:throw new Error('A React form was unexpectedly submitted.')";
2276+
"javascript:throw new Error('React form unexpectedly submitted.')";
22772277

22782278
function diffHydratedGenericElement(
22792279
domElement: Element,

packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ export function retryIfBlockedOn(
537537

538538
if (enableFormActions) {
539539
// Check the document if there are any queued form actions.
540-
const root = unblocked.getRootNode();
540+
// If there's no ownerDocument, then this is the document.
541+
const root = unblocked.ownerDocument || unblocked;
541542
const formReplayingQueue: void | FormReplayingQueue = (root: any)
542543
.$$reactFormReplay;
543544
if (formReplayingQueue != null) {

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ function makeFormFieldPrefix(resumableState: ResumableState): string {
10151015
const actionJavaScriptURL = stringToPrecomputedChunk(
10161016
escapeTextForBrowser(
10171017
// eslint-disable-next-line no-script-url
1018-
"javascript:throw new Error('A React form was unexpectedly submitted.')",
1018+
"javascript:throw new Error('React form unexpectedly submitted.')",
10191019
),
10201020
);
10211021

packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetInlineCodeStrings.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetShared.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export function completeSegment(containerID, placeholderID) {
131131
// as a shared module for that reason.
132132
const EXPECTED_FORM_ACTION_URL =
133133
// eslint-disable-next-line no-script-url
134-
"javascript:throw new Error('A React form was unexpectedly submitted.')";
134+
"javascript:throw new Error('React form unexpectedly submitted.')";
135135

136136
export function listenToFormSubmissionsForReplaying() {
137137
// A global replay queue ensures actions are replayed in order.
@@ -196,9 +196,8 @@ export function listenToFormSubmissionsForReplaying() {
196196
// javascript: URL placeholder value. So we might not be the first to declare it.
197197
// We attach it to the form's root node, which is the shared environment context
198198
// where we preserve sequencing and where we'll pick it up from during hydration.
199-
// In practice, this is just the same as document but we might support shadow trees
200-
// in the future.
201-
const root = form.getRootNode();
199+
// If there's no ownerDocument, then this is the document.
200+
const root = form.ownerDocument || form;
202201
(root['$$reactFormReplay'] = root['$$reactFormReplay'] || []).push(
203202
form,
204203
submitter,

0 commit comments

Comments
 (0)