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 3fe40fd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 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,10 @@ 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)};
svgDom.innerHTML = svgHtml;
${domInject(options.inject)}
}
if(document.readyState === 'loading') {
Expand Down

0 comments on commit 3fe40fd

Please sign in to comment.