global-node.js 915 B

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