Skip to content

Commit

Permalink
[DOM] Fix findDOMNode throw on ShadowRoot
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Feb 3, 2020
1 parent 434770c commit fc01ed9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/react-dom/src/client/ReactDOMLegacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
DOCUMENT_NODE,
ELEMENT_NODE,
COMMENT_NODE,
DOCUMENT_FRAGMENT_NODE,
} from '../shared/HTMLNodeType';

import {
Expand Down Expand Up @@ -222,7 +223,7 @@ function legacyRenderSubtreeIntoContainer(
}

export function findDOMNode(
componentOrElement: Element | ?React$Component<any, any>,
componentOrElement: Element | DocumentFragment | ?React$Component<any, any>,
): null | Element | Text {
if (__DEV__) {
let owner = (ReactCurrentOwner.current: any);
Expand All @@ -244,7 +245,8 @@ export function findDOMNode(
if (componentOrElement == null) {
return null;
}
if ((componentOrElement: any).nodeType === ELEMENT_NODE) {
const nodeType = (componentOrElement: any).nodeType;
if (nodeType === ELEMENT_NODE || nodeType === DOCUMENT_FRAGMENT_NODE) {
return (componentOrElement: any);
}
if (__DEV__) {
Expand Down

0 comments on commit fc01ed9

Please sign in to comment.