No Description

cloneNodes.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. Object.defineProperty(exports, "default", {
  6. enumerable: true,
  7. get: function() {
  8. return cloneNodes;
  9. }
  10. });
  11. function cloneNodes(nodes, source = undefined, raws = undefined) {
  12. return nodes.map((node)=>{
  13. var _node_raws_tailwind;
  14. let cloned = node.clone();
  15. // We always want override the source map
  16. // except when explicitly told not to
  17. let shouldOverwriteSource = ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.preserveSource) !== true || !cloned.source;
  18. if (source !== undefined && shouldOverwriteSource) {
  19. cloned.source = source;
  20. if ("walk" in cloned) {
  21. cloned.walk((child)=>{
  22. child.source = source;
  23. });
  24. }
  25. }
  26. if (raws !== undefined) {
  27. cloned.raws.tailwind = {
  28. ...cloned.raws.tailwind,
  29. ...raws
  30. };
  31. }
  32. return cloned;
  33. });
  34. }