File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,13 @@ interface InPortalProps {
2424 children : React . ReactNode ;
2525}
2626
27- export const createPortalNode = < C extends Component < any > > ( ) : PortalNode < C > => {
27+ export const createPortalNode = < C extends Component < any > > ( tagName : string = 'div' ) : PortalNode < C > => {
2828 let initialProps = { } as ComponentProps < C > ;
2929
3030 let parent : Node | undefined ;
3131 let lastPlaceholder : Node | undefined ;
3232
33- const portalNode = Object . assign ( document . createElement ( 'div' ) , {
33+ const portalNode = Object . assign ( document . createElement ( tagName ) , {
3434 setPortalProps : ( props : ComponentProps < C > ) => {
3535 initialProps = props ;
3636 } ,
@@ -165,9 +165,11 @@ export class OutPortal<C extends Component<any>> extends React.PureComponent<Out
165165 }
166166
167167 render ( ) {
168+ const { tagName : NodeTagName } = this . props . node ;
169+
168170 // Render a placeholder to the DOM, so we can get a reference into
169171 // our location in the DOM, and swap it out for the portaled node.
170- return < div ref = { this . placeholderNode } /> ;
172+ return < NodeTagName ref = { this . placeholderNode } /> ;
171173 }
172174
173- }
175+ }
Original file line number Diff line number Diff line change @@ -227,7 +227,7 @@ storiesOf('Portals', module)
227227 </ div > ;
228228 } )
229229 . add ( 'Works with SVGs' , ( ) => {
230- const portalNode = portals . createPortalNode ( ) ;
230+ const portalNode = portals . createPortalNode ( 'text' ) ;
231231
232232 // From https://github.com/httptoolkit/react-reverse-portal/issues/2
233233 return < div >
You can’t perform that action at this time.
0 commit comments