File tree Expand file tree Collapse file tree 3 files changed +87
-6
lines changed
enzyme-adapter-react-16.1/src
enzyme-adapter-react-16.2/src
enzyme-adapter-react-16/src Expand file tree Collapse file tree 3 files changed +87
-6
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,8 @@ import {
1616import { EnzymeAdapter } from 'enzyme' ;
1717import {
1818 displayNameOfNode ,
19- elementToTree ,
20- nodeTypeFromType ,
19+ elementToTree as utilElementToTree ,
20+ nodeTypeFromType as utilNodeTypeFromType ,
2121 mapNativeEventNames ,
2222 propFromEvent ,
2323 assertDomAvailable ,
@@ -72,6 +72,33 @@ function flatten(arr) {
7272 return result ;
7373}
7474
75+ function nodeTypeFromType ( type ) {
76+ if ( type && type === Portal ) {
77+ return 'portal' ;
78+ }
79+
80+ return utilNodeTypeFromType ( type ) ;
81+ }
82+
83+ function elementToTree ( el ) {
84+ if ( ! ( el && el . $$typeof === Portal ) ) {
85+ return utilElementToTree ( el , elementToTree ) ;
86+ }
87+
88+ const { children, containerInfo } = el ;
89+ const props = { children, containerInfo } ;
90+
91+ return {
92+ nodeType : 'portal' ,
93+ type : Portal ,
94+ props,
95+ key : ensureKeyOrUndefined ( el . key ) ,
96+ ref : el . ref ,
97+ instance : null ,
98+ rendered : elementToTree ( el . children ) ,
99+ } ;
100+ }
101+
75102function toTree ( vnode ) {
76103 if ( vnode == null ) {
77104 return null ;
Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ import { EnzymeAdapter } from 'enzyme';
1717import { typeOfNode } from 'enzyme/build/Utils' ;
1818import {
1919 displayNameOfNode ,
20- elementToTree ,
21- nodeTypeFromType ,
20+ elementToTree as utilElementToTree ,
21+ nodeTypeFromType as utilNodeTypeFromType ,
2222 mapNativeEventNames ,
2323 propFromEvent ,
2424 assertDomAvailable ,
@@ -73,6 +73,33 @@ function flatten(arr) {
7373 return result ;
7474}
7575
76+ function nodeTypeFromType ( type ) {
77+ if ( type && type === Portal ) {
78+ return 'portal' ;
79+ }
80+
81+ return utilNodeTypeFromType ( type ) ;
82+ }
83+
84+ function elementToTree ( el ) {
85+ if ( ! ( el && el . $$typeof === Portal ) ) {
86+ return utilElementToTree ( el , elementToTree ) ;
87+ }
88+
89+ const { children, containerInfo } = el ;
90+ const props = { children, containerInfo } ;
91+
92+ return {
93+ nodeType : 'portal' ,
94+ type : Portal ,
95+ props,
96+ key : ensureKeyOrUndefined ( el . key ) ,
97+ ref : el . ref ,
98+ instance : null ,
99+ rendered : elementToTree ( el . children ) ,
100+ } ;
101+ }
102+
76103function toTree ( vnode ) {
77104 if ( vnode == null ) {
78105 return null ;
Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ import { EnzymeAdapter } from 'enzyme';
2424import { typeOfNode } from 'enzyme/build/Utils' ;
2525import {
2626 displayNameOfNode ,
27- elementToTree ,
28- nodeTypeFromType ,
27+ elementToTree as utilElementToTree ,
28+ nodeTypeFromType as utilNodeTypeFromType ,
2929 mapNativeEventNames ,
3030 propFromEvent ,
3131 assertDomAvailable ,
@@ -78,6 +78,33 @@ function flatten(arr) {
7878 return result ;
7979}
8080
81+ function nodeTypeFromType ( type ) {
82+ if ( type && type === Portal ) {
83+ return 'portal' ;
84+ }
85+
86+ return utilNodeTypeFromType ( type ) ;
87+ }
88+
89+ function elementToTree ( el ) {
90+ if ( ! ( el && el . $$typeof === Portal ) ) {
91+ return utilElementToTree ( el , elementToTree ) ;
92+ }
93+
94+ const { children, containerInfo } = el ;
95+ const props = { children, containerInfo } ;
96+
97+ return {
98+ nodeType : 'portal' ,
99+ type : Portal ,
100+ props,
101+ key : ensureKeyOrUndefined ( el . key ) ,
102+ ref : el . ref ,
103+ instance : null ,
104+ rendered : elementToTree ( el . children ) ,
105+ } ;
106+ }
107+
81108function toTree ( vnode ) {
82109 if ( vnode == null ) {
83110 return null ;
You can’t perform that action at this time.
0 commit comments