Skip to content

Commit ce0f272

Browse files
committed
[DOM] Fix findDOMNode throw on ShadowRoot
1 parent 99d2712 commit ce0f272

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/react-dom/src/client/ReactDOMLegacy.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
DOCUMENT_NODE,
2323
ELEMENT_NODE,
2424
COMMENT_NODE,
25+
DOCUMENT_FRAGMENT_NODE,
2526
} from '../shared/HTMLNodeType';
2627

2728
import {
@@ -222,7 +223,7 @@ function legacyRenderSubtreeIntoContainer(
222223
}
223224

224225
export function findDOMNode(
225-
componentOrElement: Element | ?React$Component<any, any>,
226+
componentOrElement: Element | DocumentFragment | ?React$Component<any, any>,
226227
): null | Element | Text {
227228
if (__DEV__) {
228229
let owner = (ReactCurrentOwner.current: any);
@@ -244,7 +245,8 @@ export function findDOMNode(
244245
if (componentOrElement == null) {
245246
return null;
246247
}
247-
if ((componentOrElement: any).nodeType === ELEMENT_NODE) {
248+
const nodeType = (componentOrElement: any).nodeType;
249+
if (nodeType === ELEMENT_NODE || nodeType === DOCUMENT_FRAGMENT_NODE) {
248250
return (componentOrElement: any);
249251
}
250252
if (__DEV__) {

0 commit comments

Comments
 (0)