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.

removeNonInheritableGroupAttrs.js 945B

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. };