element-plus
Version:
A Component Library for Vue 3
1 lines • 1.21 kB
Source Map (JSON)
{"version":3,"file":"global-nodes.mjs","sources":["../../../../packages/utils/global-nodes.ts"],"sourcesContent":["import isServer from './isServer'\n\nconst globalNodes = []\nlet target = isServer ? undefined : document.body\n\nexport function createGlobalNode(id?: string) {\n const el = document.createElement('div')\n\n if (id !== undefined) {\n el.id = id\n }\n\n target.appendChild(el)\n globalNodes.push(el)\n\n return el\n}\n\nexport function removeGlobalNode(el: HTMLElement) {\n globalNodes.splice(globalNodes.indexOf(el), 1)\n el.remove()\n}\n\nexport function changeGlobalNodesTarget(el: HTMLElement) {\n if (el !== target) {\n target = el\n\n globalNodes.forEach((el) => {\n if (el.contains(target) === false) {\n target.appendChild(el)\n }\n })\n }\n}\n"],"names":[],"mappings":";;AAEA,MAAM,cAAc;AACpB,IAAI,SAAS,WAAW,SAAY,SAAS;0BAEZ,IAAa;AAC5C,QAAM,KAAK,SAAS,cAAc;AAElC,MAAI,OAAO,QAAW;AACpB,OAAG,KAAK;AAAA;AAGV,SAAO,YAAY;AACnB,cAAY,KAAK;AAEjB,SAAO;AAAA;0BAGwB,IAAiB;AAChD,cAAY,OAAO,YAAY,QAAQ,KAAK;AAC5C,KAAG;AAAA;iCAGmC,IAAiB;AACvD,MAAI,OAAO,QAAQ;AACjB,aAAS;AAET,gBAAY,QAAQ,CAAC,QAAO;AAC1B,UAAI,IAAG,SAAS,YAAY,OAAO;AACjC,eAAO,YAAY;AAAA;AAAA;AAAA;AAAA;;;;"}