File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed 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 ownerDocument : container . ownerDocument ,
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 @@ -875,4 +875,35 @@ describe('Portal', () => {
875875 'Portal'
876876 ] ) ;
877877 } ) ;
878+
879+ // #4992
880+ it ( 'should maintain SVG namespace when rendering through a portal' , ( ) => {
881+ const svgRoot = document . createElementNS (
882+ 'http://www.w3.org/2000/svg' ,
883+ 'svg'
884+ ) ;
885+ document . body . appendChild ( svgRoot ) ;
886+
887+ function App ( ) {
888+ return (
889+ < svg >
890+ < g >
891+ < rect width = "100" height = "100" fill = "red" />
892+ { createPortal (
893+ < g id = "test-portal" >
894+ < rect width = "50" height = "50" fill = "blue" />
895+ </ g > ,
896+ svgRoot
897+ ) }
898+ </ g >
899+ </ svg >
900+ ) ;
901+ }
902+
903+ render ( < App /> , scratch ) ;
904+
905+ const portalG = svgRoot . querySelector ( 'g#test-portal' ) ;
906+ expect ( portalG . namespaceURI ) . to . equal ( 'http://www.w3.org/2000/svg' ) ;
907+ expect ( portalG . constructor . name ) . to . equal ( 'SVGGElement' ) ;
908+ } ) ;
878909} ) ;
You can’t perform that action at this time.
0 commit comments