Batched state changes are not flushed if the promise code changes the DOM (= attaching an iframe). Reproduceable with Safari.

React version: 18.1.0

## Steps To Reproduce

1. Open [codepen](https://codepen.io/kh-viewar/pen/wvpVLxM) with Safari.
2. Click "Upload"
3. => "Spinner" text does not render while Promise is in pending

Link to code example:

https://codepen.io/kh-viewar/pen/wvpVLxM

## The current behavior

State changes are not executed.

## The expected behavior

State should change to true and render spinner component. After promise is resolved (2 seconds timeout), state should switch back to false and spinner component should unmount.

## Original discussion

https://github.com/facebook/react/issues/24365
let executionContext: ExecutionContext = NoContext;
let workInProgressRoot: FiberRoot | null = null;
let workInProgress: Fiber | null = null;
let workInProgressRootRenderLanes: Lanes = NoLanes;
export let subtreeRenderLanes: Lanes = NoLanes;
const subtreeRenderLanesCursor: StackCursor<Lanes> = createCursor(NoLanes);
 Whether to root completed, errored, suspended, etc.
let workInProgressRootExitStatus: RootExitStatus = RootInProgress;
 A fatal error, if one is thrown
let workInProgressRootFatalError: mixed = null;
 "Included" lanes refer to lanes that were worked on during  It's
 slightly different than `renderLanes` because `renderLanes` can change as you
 enter and exit an Offscreen tree. This value is the combination of all render
 lanes for the entire render phase.
let workInProgressRootIncludedLanes: Lanes = NoLanes;
 The work left over by components that were visited during  Only
 includes unprocessed updates, not work in bailed out children.
let workInProgressRootSkippedLanes: Lanes = NoLanes;
 Lanes that were updated (in an interleaved event) during 
let workInProgressRootInterleavedUpdatedLanes: Lanes = NoLanes;
 Lanes that were updated during the render phase (*not* an interleaved event).
let workInProgressRootRenderPhaseUpdatedLanes: Lanes = NoLanes;
 Lanes that were pinged (in an interleaved event) during 
let workInProgressRootPingedLanes: Lanes = NoLanes;
 Errors that are thrown during 
let workInProgressRootConcurrentErrors: Array<mixed> | null = null;
 These are errors that we recovered from without surfacing them to the UI.
 We will log them once the tree commits.
let workInProgressRootRecoverableErrors: Array<mixed> | null = null;
 The most recent time we committed a fallback. This lets us ensure a train