diff --git a/libs/horizon/src/dom/utils/DomCreator.ts b/libs/horizon/src/dom/utils/DomCreator.ts index 360aea81..9d89ef5f 100644 --- a/libs/horizon/src/dom/utils/DomCreator.ts +++ b/libs/horizon/src/dom/utils/DomCreator.ts @@ -5,6 +5,13 @@ export const NSS = { svg: 'http://www.w3.org/2000/svg', }; +const div = document.createElement('div'); +const span = document.createElement('span'); +const tr = document.createElement('tr'); +const td = document.createElement('td'); +const a = document.createElement('a'); +const p = document.createElement('p'); + // 创建DOM元素 export function createDom( tagName: string, @@ -16,6 +23,18 @@ export function createDom( if (ns !== NSS.html) { dom = document.createElementNS(ns, tagName); + } else if (tagName === 'div') { + dom = div.cloneNode(false); + } else if (tagName === 'span') { + dom = span.cloneNode(false); + } else if (tagName === 'tr') { + dom = tr.cloneNode(false); + } else if (tagName === 'td') { + dom = td.cloneNode(false); + } else if (tagName === 'a') { + dom = a.cloneNode(false); + } else if (tagName === 'p') { + dom = p.cloneNode(false); } else { dom = document.createElement(tagName); }