removeNonInheritableGroupAttrs.js 945 B

12345678910111213141516171819202122232425262728293031323334353637
  1. 'use strict';
  2. exports.type = 'perItem';
  3. exports.active = true;
  4. exports.description = 'removes non-inheritable group’s presentational attributes';
  5. var inheritableAttrs = require('./_collections').inheritableAttrs,
  6. attrsGroups = require('./_collections').attrsGroups,
  7. applyGroups = require('./_collections').presentationNonInheritableGroupAttrs;
  8. /**
  9. * Remove non-inheritable group's "presentation" attributes.
  10. *
  11. * @param {Object} item current iteration item
  12. * @return {Boolean} if false, item will be filtered out
  13. *
  14. * @author Kir Belevich
  15. */
  16. exports.fn = function(item) {
  17. if (item.isElem('g')) {
  18. item.eachAttr(function(attr) {
  19. if (
  20. ~attrsGroups.presentation.indexOf(attr.name) &&
  21. !~inheritableAttrs.indexOf(attr.name) &&
  22. !~applyGroups.indexOf(attr.name)
  23. ) {
  24. item.removeAttr(attr.name);
  25. }
  26. });
  27. }
  28. };