From 5522114eaf4eaac3fbecbfb19701c60761bf3a79 Mon Sep 17 00:00:00 2001 From: yout <930222789@qq.com> Date: Fri, 2 Feb 2024 12:32:42 +0800 Subject: [PATCH] feat: using append-html mode to avoid overwriting existing htmls (close #83) --- packages/core/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 2c2df24..0726499 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -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'; @@ -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') {