Skip to content

Commit 8710c01

Browse files
authored
fix: nodeRef prop type for cross-realm elements (#732)
1 parent 7b23603 commit 8710c01

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/Transition.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,18 @@ Transition.propTypes = {
391391
* [test/CSSTransition-test.js](https://github.com/reactjs/react-transition-group/blob/13435f897b3ab71f6e19d724f145596f5910581c/test/CSSTransition-test.js#L362-L437)).
392392
*/
393393
nodeRef: PropTypes.shape({
394-
current: typeof Element === 'undefined'
395-
? PropTypes.any
396-
: PropTypes.instanceOf(Element)
394+
current:
395+
typeof Element === 'undefined'
396+
? PropTypes.any
397+
: (propValue, key, componentName, location, propFullName, secret) => {
398+
const value = propValue[key];
399+
400+
return PropTypes.instanceOf(
401+
value && 'ownerDocument' in value
402+
? value.ownerDocument.defaultView.Element
403+
: Element
404+
)(propValue, key, componentName, location, propFullName, secret);
405+
},
397406
}),
398407

399408
/**

0 commit comments

Comments
 (0)