removeEmptyContainers.js 690 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. exports.type = 'perItemReverse';
  3. exports.active = true;
  4. exports.description = 'removes empty container elements';
  5. var container = require('./_collections').elemsGroups.container;
  6. /**
  7. * Remove empty containers.
  8. *
  9. * @see http://www.w3.org/TR/SVG/intro.html#TermContainerElement
  10. *
  11. * @example
  12. * <defs/>
  13. *
  14. * @example
  15. * <g><marker><a/></marker></g>
  16. *
  17. * @param {Object} item current iteration item
  18. * @return {Boolean} if false, item will be filtered out
  19. *
  20. * @author Kir Belevich
  21. */
  22. exports.fn = function(item) {
  23. return !(item.isElem(container) && !item.isElem('svg') && item.isEmpty() &&
  24. (!item.isElem('pattern') || !item.hasAttrLocal('href')));
  25. };