Skip to content

Commit

Permalink
s/getRootNode/ownerDocument (facebook#28412)
Browse files Browse the repository at this point in the history
getRootNode isn't always available, use ownerDocument instead
  • Loading branch information
rickhanlonii authored and AndyPengc12 committed Apr 15, 2024
1 parent 58c3f5b commit 9c987a3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ function diffHydratedCustomComponent(
// as a shared module for that reason.
const EXPECTED_FORM_ACTION_URL =
// eslint-disable-next-line no-script-url
"javascript:throw new Error('A React form was unexpectedly submitted.')";
"javascript:throw new Error('React form unexpectedly submitted.')";

function diffHydratedGenericElement(
domElement: Element,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,8 @@ export function retryIfBlockedOn(

if (enableFormActions) {
// Check the document if there are any queued form actions.
const root = unblocked.getRootNode();
// 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ function makeFormFieldPrefix(resumableState: ResumableState): string {
const actionJavaScriptURL = stringToPrecomputedChunk(
escapeTextForBrowser(
// eslint-disable-next-line no-script-url
"javascript:throw new Error('A React form was unexpectedly submitted.')",
"javascript:throw new Error('React form unexpectedly submitted.')",
),
);

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

export function listenToFormSubmissionsForReplaying() {
// A global replay queue ensures actions are replayed in order.
Expand Down Expand Up @@ -196,9 +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.
// In practice, this is just the same as document but we might support shadow trees
// in the future.
const root = form.getRootNode();
// If there's no ownerDocument, then this is the document.
const root = form.ownerDocument || form;
(root['$$reactFormReplay'] = root['$$reactFormReplay'] || []).push(
form,
submitter,
Expand Down

0 comments on commit 9c987a3

Please sign in to comment.