removeNonInheritableGroupAttrs.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. excludedAttrs = ['display', 'opacity'];
  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. ~attrsGroups.graphicalEvent.indexOf(attr.name) &&
  22. ~attrsGroups.core.indexOf(attr.name) &&
  23. ~attrsGroups.conditionalProcessing.indexOf(attr.name) &&
  24. !~excludedAttrs.indexOf(attr.name) &&
  25. !~inheritableAttrs.indexOf(attr.name)
  26. ) {
  27. item.removeAttr(attr.name);
  28. }
  29. });
  30. }
  31. };