From 8710c01549e09f55eeefec2aadb3af0a23a00f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sat, 29 May 2021 16:47:38 +0200 Subject: [PATCH] fix: `nodeRef` prop type for cross-realm elements (#732) --- src/Transition.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Transition.js b/src/Transition.js index 981acc26..68c3b02c 100644 --- a/src/Transition.js +++ b/src/Transition.js @@ -391,9 +391,18 @@ Transition.propTypes = { * [test/CSSTransition-test.js](https://github.com/reactjs/react-transition-group/blob/13435f897b3ab71f6e19d724f145596f5910581c/test/CSSTransition-test.js#L362-L437)). */ nodeRef: PropTypes.shape({ - current: typeof Element === 'undefined' - ? PropTypes.any - : PropTypes.instanceOf(Element) + current: + typeof Element === 'undefined' + ? PropTypes.any + : (propValue, key, componentName, location, propFullName, secret) => { + const value = propValue[key]; + + return PropTypes.instanceOf( + value && 'ownerDocument' in value + ? value.ownerDocument.defaultView.Element + : Element + )(propValue, key, componentName, location, propFullName, secret); + }, }), /**