Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compat/src/portals.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function Portal(props) {
childNodes: [],
_children: { _mask: root._mask },
contains: () => true,
namespaceURI: container.namespaceURI,
insertBefore(child, before) {
this.childNodes.push(child);
_this._container.insertBefore(child, before);
Expand Down
31 changes: 31 additions & 0 deletions compat/test/browser/portals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -874,4 +874,35 @@ describe('Portal', () => {
'Portal'
]);
});

// #4992
it('should maintain SVG namespace when rendering through a portal', () => {
const svgRoot = document.createElementNS(
'http://www.w3.org/2000/svg',
'svg'
);
document.body.appendChild(svgRoot);

function App() {
return (
<svg>
<g>
<rect width="100" height="100" fill="red" />
{createPortal(
<g id="test-portal">
<rect width="50" height="50" fill="blue" />
</g>,
svgRoot
)}
</g>
</svg>
);
}

render(<App />, scratch);

const portalG = svgRoot.querySelector('g#test-portal');
expect(portalG.namespaceURI).to.equal('http://www.w3.org/2000/svg');
expect(portalG.constructor.name).to.equal('SVGGElement');
});
});
Loading