Skip to content

Commit

Permalink
feat: using append-html mode to avoid overwriting existing htmls (close
Browse files Browse the repository at this point in the history
  • Loading branch information
youthug committed Feb 2, 2024
1 parent 7550357 commit 5522114
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export async function createModuleCode(
function loadSvg() {
var body = document.body;
var svgDom = document.getElementById('${options.customDomId}');
var svgHtml = ${JSON.stringify(html)};
if(!svgDom) {
svgDom = document.createElementNS('${XMLNS}', 'svg');
svgDom.style.position = 'absolute';
Expand All @@ -136,8 +137,9 @@ export async function createModuleCode(
svgDom.id = '${options.customDomId}';
svgDom.setAttribute('xmlns','${XMLNS}');
svgDom.setAttribute('xmlns:link','${XMLNS_LINK}');
} else {
svgHtml = (svgDom.innerHTML || '') + svgHtml;
}
svgDom.innerHTML = ${JSON.stringify(html)};
${domInject(options.inject)}
}
if(document.readyState === 'loading') {
Expand Down

0 comments on commit 5522114

Please sign in to comment.