removeXMLNS.js 666 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. exports.name = 'removeXMLNS';
  3. exports.type = 'perItem';
  4. exports.active = false;
  5. exports.description =
  6. 'removes xmlns attribute (for inline svg, disabled by default)';
  7. /**
  8. * Remove the xmlns attribute when present.
  9. *
  10. * @example
  11. * <svg viewBox="0 0 100 50" xmlns="http://www.w3.org/2000/svg">
  12. * ↓
  13. * <svg viewBox="0 0 100 50">
  14. *
  15. * @param {Object} item current iteration item
  16. * @return {Boolean} if true, xmlns will be filtered out
  17. *
  18. * @author Ricardo Tomasi
  19. */
  20. exports.fn = function (item) {
  21. if (item.type === 'element' && item.name === 'svg') {
  22. delete item.attributes.xmlns;
  23. delete item.attributes['xmlns:xlink'];
  24. }
  25. };