File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ function Portal(props) {
4747 childNodes : [ ] ,
4848 _children : { _mask : root . _mask } ,
4949 contains : ( ) => true ,
50+ namespaceURI : container . namespaceURI ,
5051 insertBefore ( child , before ) {
5152 this . childNodes . push ( child ) ;
5253 _this . _container . insertBefore ( child , before ) ;
Original file line number Diff line number Diff line change @@ -874,4 +874,35 @@ describe('Portal', () => {
874874 'Portal'
875875 ] ) ;
876876 } ) ;
877+
878+ // #4992
879+ it ( 'should maintain SVG namespace when rendering through a portal' , ( ) => {
880+ const svgRoot = document . createElementNS (
881+ 'http://www.w3.org/2000/svg' ,
882+ 'svg'
883+ ) ;
884+ document . body . appendChild ( svgRoot ) ;
885+
886+ function App ( ) {
887+ return (
888+ < svg >
889+ < g >
890+ < rect width = "100" height = "100" fill = "red" />
891+ { createPortal (
892+ < g id = "test-portal" >
893+ < rect width = "50" height = "50" fill = "blue" />
894+ </ g > ,
895+ svgRoot
896+ ) }
897+ </ g >
898+ </ svg >
899+ ) ;
900+ }
901+
902+ render ( < App /> , scratch ) ;
903+
904+ const portalG = svgRoot . querySelector ( 'g#test-portal' ) ;
905+ expect ( portalG . namespaceURI ) . to . equal ( 'http://www.w3.org/2000/svg' ) ;
906+ expect ( portalG . constructor . name ) . to . equal ( 'SVGGElement' ) ;
907+ } ) ;
877908} ) ;
You can’t perform that action at this time.
0 commit comments