You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.0 KiB

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