File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed
Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 3636 "dependencies" : {
3737 "function.prototype.name" : " ^1.1.0" ,
3838 "object.assign" : " ^4.1.0" ,
39- "prop-types" : " ^15.6.2"
39+ "prop-types" : " ^15.6.2" ,
40+ "react-is" : " ^16.4.2"
4041 },
4142 "peerDependencies" : {
4243 "react" : " 0.13.x || 0.14.x || ^15.0.0-0 || ^16.0.0-0"
Original file line number Diff line number Diff line change 11import functionName from 'function.prototype.name' ;
22import createMountWrapper from './createMountWrapper' ;
33import createRenderWrapper from './createRenderWrapper' ;
4+ import {
5+ Portal ,
6+ } from 'react-is' ;
47
58export { createMountWrapper , createRenderWrapper } ;
69
@@ -94,6 +97,10 @@ export function displayNameOfNode(node) {
9497
9598 if ( ! type ) return null ;
9699
100+ if ( type === Portal ) {
101+ return 'Portal' ;
102+ }
103+
97104 return type . displayName || ( typeof type === 'function' ? functionName ( type ) : type . name || type ) ;
98105}
99106
@@ -104,6 +111,9 @@ export function nodeTypeFromType(type) {
104111 if ( type && type . prototype && type . prototype . isReactComponent ) {
105112 return 'class' ;
106113 }
114+ if ( type && type === Portal ) {
115+ return 'portal' ;
116+ }
107117 return 'function' ;
108118}
109119
@@ -168,9 +178,20 @@ export function ensureKeyOrUndefined(key) {
168178}
169179
170180export function elementToTree ( el ) {
171- if ( el === null || typeof el !== 'object' || ! ( 'type' in el ) ) {
181+ if ( el === null || typeof el !== 'object' || ! ( 'type' in el || el . $$typeof === Portal ) ) {
172182 return el ;
173183 }
184+ if ( el . $$typeof === Portal ) {
185+ return {
186+ nodeType : nodeTypeFromType ( Portal ) ,
187+ type : Portal ,
188+ props : { } ,
189+ key : ensureKeyOrUndefined ( el . key ) ,
190+ ref : el . ref ,
191+ instance : null ,
192+ rendered : elementToTree ( el . children ) ,
193+ } ;
194+ }
174195 const {
175196 type,
176197 props,
Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ import {
3535 REACT16 ,
3636 is ,
3737} from './_helpers/version' ;
38+ import {
39+ Portal ,
40+ } from 'react-is' ;
3841import realArrowFunction from './_helpers/realArrowFunction' ;
3942import sloppyReturnThis from './_helpers/untranspiledSloppyReturnThis' ;
4043
You can’t perform that action at this time.
0 commit comments