global-node.js 914 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. if (target) {
  12. target.appendChild(el);
  13. globalNodes.push(el);
  14. }
  15. return el;
  16. }
  17. function removeGlobalNode(el) {
  18. globalNodes.splice(globalNodes.indexOf(el), 1);
  19. el.remove();
  20. }
  21. function changeGlobalNodesTarget(el) {
  22. if (el === target)
  23. return;
  24. target = el;
  25. globalNodes.forEach((el2) => {
  26. if (target && !el2.contains(target)) {
  27. target.appendChild(el2);
  28. }
  29. });
  30. }
  31. exports.changeGlobalNodesTarget = changeGlobalNodesTarget;
  32. exports.createGlobalNode = createGlobalNode;
  33. exports.removeGlobalNode = removeGlobalNode;
  34. //# sourceMappingURL=global-node.js.map