diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js index d70d1fdbb381c..e9948f04119a3 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -325,7 +325,7 @@ export function getPublicInstance(instance: Instance): Instance { export function prepareForCommit(containerInfo: Container): Object | null { eventsEnabled = ReactBrowserEventEmitterIsEnabled(); - selectionInformation = getSelectionInformation(); + selectionInformation = getSelectionInformation(containerInfo); let activeInstance = null; if (enableCreateEventHandleAPI) { const focusedElem = selectionInformation.focusedElem; diff --git a/packages/react-dom-bindings/src/client/ReactInputSelection.js b/packages/react-dom-bindings/src/client/ReactInputSelection.js index 1a3d63b367f6f..de853b5ee9216 100644 --- a/packages/react-dom-bindings/src/client/ReactInputSelection.js +++ b/packages/react-dom-bindings/src/client/ReactInputSelection.js @@ -56,9 +56,12 @@ function isSameOriginFrame(iframe) { } } -function getActiveElementDeep() { +function getActiveElementDeep(containerInfo) { let win = window; - let element = getActiveElement(); + if (containerInfo?.ownerDocument?.defaultView) { + win = containerInfo.ownerDocument.defaultView + } + let element = getActiveElement(win.document); while (element instanceof win.HTMLIFrameElement) { if (isSameOriginFrame(element)) { win = element.contentWindow; @@ -97,8 +100,8 @@ export function hasSelectionCapabilities(elem) { ); } -export function getSelectionInformation() { - const focusedElem = getActiveElementDeep(); +export function getSelectionInformation(containerInfo) { + const focusedElem = getActiveElementDeep(containerInfo); return { focusedElem: focusedElem, selectionRange: hasSelectionCapabilities(focusedElem) @@ -112,8 +115,8 @@ export function getSelectionInformation() { * restore it. This is useful when performing operations that could remove dom * nodes and place them back in, resulting in focus being lost. */ -export function restoreSelection(priorSelectionInformation) { - const curFocusedElem = getActiveElementDeep(); +export function restoreSelection(priorSelectionInformation, containerInfo) { + const curFocusedElem = getActiveElementDeep(containerInfo); const priorFocusedElem = priorSelectionInformation.focusedElem; const priorSelectionRange = priorSelectionInformation.selectionRange; if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) { diff --git a/packages/shared/ReactVersion.js b/packages/shared/ReactVersion.js index 13dd40e747e0d..0930479b81b6b 100644 --- a/packages/shared/ReactVersion.js +++ b/packages/shared/ReactVersion.js @@ -1,15 +1 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// TODO: this is special because it gets imported during build. -// -// It exists as a placeholder so that DevTools can support work tag changes between releases. -// When we next publish a release, update the matching TODO in backend/renderer.js -// TODO: This module is used both by the release scripts and to expose a version -// at runtime. We should instead inject the version number as part of the build -// process, and use the ReactVersions.js module as the single source of truth. -export default '19.0.0'; +export default '19.0.0-rc-d6cb4e77-20240911';