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.

33 lines
772 B

4 years ago
  1. var wrapSingle = require('../wrap-for-optimizing').single;
  2. var Token = require('../../tokenizer/token');
  3. function deep(property) {
  4. var cloned = shallow(property);
  5. for (var i = property.components.length - 1; i >= 0; i--) {
  6. var component = shallow(property.components[i]);
  7. component.value = property.components[i].value.slice(0);
  8. cloned.components.unshift(component);
  9. }
  10. cloned.dirty = true;
  11. cloned.value = property.value.slice(0);
  12. return cloned;
  13. }
  14. function shallow(property) {
  15. var cloned = wrapSingle([
  16. Token.PROPERTY,
  17. [Token.PROPERTY_NAME, property.name]
  18. ]);
  19. cloned.important = property.important;
  20. cloned.hack = property.hack;
  21. cloned.unused = false;
  22. return cloned;
  23. }
  24. module.exports = {
  25. deep: deep,
  26. shallow: shallow
  27. };