Skip to content

Commit 92a6fd5

Browse files
committed
fix: svg elements not getting rendered properly in live preview when a new svg type element is added
1 parent 96669c8 commit 92a6fd5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5272,8 +5272,16 @@ function RemoteFunctions(config = {}) {
52725272
editIsSpecialTag = false;
52735273
}
52745274
}
5275+
52755276
if (!editIsSpecialTag) {
5276-
childElement = self.htmlDocument.createElement(edit.tag);
5277+
// If the parent element is an instance of SVGElement or we're inserting an <svg> tag directly,
5278+
// we need to create it in the SVG namespace otherwise SVG elements won't render
5279+
// correctly in live preview until it's reloaded
5280+
if (targetElement instanceof SVGElement || edit.tag.toLowerCase() === "svg") {
5281+
childElement = self.htmlDocument.createElementNS("http://www.w3.org/2000/svg", edit.tag);
5282+
} else {
5283+
childElement = self.htmlDocument.createElement(edit.tag);
5284+
}
52775285
}
52785286

52795287
Object.keys(edit.attributes).forEach(function (attr) {

0 commit comments

Comments
 (0)