JSFiddle - React, Tailwind, and code Playground
HTML
<object id="obj"></object>
JavaScript
// an svg string
const svgStr = `<svg width="120" height="120" viewBox="0 0 120 120"
xmlns="http://www.w3.org/2000/svg">
<rect x="10" y="10" width="100" height="100"/>
</svg>`;
// first load an same-origin document (not sure if about:blank works in IE...)
obj.data = 'about:blank';
// once it has loaded
obj.onload = e => {
// parse our svgString to a DOM element
const svgDoc = new DOMParser().parseFromString(svgStr, 'image/svg+xml');
const objDoc = obj.contentDocument;
// ask the object's document to adopt the svg node
const toAppend = objDoc.adoptNode(svgDoc.documentElement);
// now we can append it and it will display
objDoc.documentElement.appendChild(toAppend);
// and we can even edit it
setTimeout(() => objDoc.querySelector('rect')
.setAttribute('fill', 'red')
, 2000);
};