removeEmptyAttrs.js 509 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. exports.type = 'perItem';
  3. exports.active = true;
  4. exports.description = 'removes empty attributes';
  5. /**
  6. * Remove attributes with empty values.
  7. *
  8. * @param {Object} item current iteration item
  9. * @return {Boolean} if false, item will be filtered out
  10. *
  11. * @author Kir Belevich
  12. */
  13. exports.fn = function(item) {
  14. if (item.elem) {
  15. item.eachAttr(function(attr) {
  16. if (attr.value === '') {
  17. item.removeAttr(attr.name);
  18. }
  19. });
  20. }
  21. };