global-node.js 889 B

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var core = require('@vueuse/core');
  4. const globalNodes = [];
  5. let target = !core.isClient ? void 0 : document.body;
  6. function createGlobalNode(id) {
  7. const el = document.createElement("div");
  8. if (id !== void 0) {
  9. el.setAttribute("id", id);
  10. }
  11. target.appendChild(el);
  12. globalNodes.push(el);
  13. return el;
  14. }
  15. function removeGlobalNode(el) {
  16. globalNodes.splice(globalNodes.indexOf(el), 1);
  17. el.remove();
  18. }
  19. function changeGlobalNodesTarget(el) {
  20. if (el === target)
  21. return;
  22. target = el;
  23. globalNodes.forEach((el2) => {
  24. if (el2.contains(target) === false) {
  25. target.appendChild(el2);
  26. }
  27. });
  28. }
  29. exports.changeGlobalNodesTarget = changeGlobalNodesTarget;
  30. exports.createGlobalNode = createGlobalNode;
  31. exports.removeGlobalNode = removeGlobalNode;
  32. //# sourceMappingURL=global-node.js.map