89e89e2f5c2f1a548e02712f111d85492df106299986e29fb3e936ce8a0b5b86e21c2d9a4d4741ca1e9fdf94270e4d6861da18092e9a4ce09bf2704a34db0c 925 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. exports.name = 'removeNonInheritableGroupAttrs';
  3. exports.type = 'perItem';
  4. exports.active = true;
  5. exports.description =
  6. 'removes non-inheritable group’s presentational attributes';
  7. const {
  8. inheritableAttrs,
  9. attrsGroups,
  10. presentationNonInheritableGroupAttrs,
  11. } = require('./_collections');
  12. /**
  13. * Remove non-inheritable group's "presentation" attributes.
  14. *
  15. * @param {Object} item current iteration item
  16. * @return {Boolean} if false, item will be filtered out
  17. *
  18. * @author Kir Belevich
  19. */
  20. exports.fn = function (item) {
  21. if (item.type === 'element' && item.name === 'g') {
  22. for (const name of Object.keys(item.attributes)) {
  23. if (
  24. attrsGroups.presentation.includes(name) === true &&
  25. inheritableAttrs.includes(name) === false &&
  26. presentationNonInheritableGroupAttrs.includes(name) === false
  27. ) {
  28. delete item.attributes[name];
  29. }
  30. }
  31. }
  32. };