removeStyleElement.js 604 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const { detachNodeFromParent } = require('../lib/xast.js');
  3. exports.name = 'removeStyleElement';
  4. exports.type = 'visitor';
  5. exports.active = false;
  6. exports.description = 'removes <style> element (disabled by default)';
  7. /**
  8. * Remove <style>.
  9. *
  10. * https://www.w3.org/TR/SVG11/styling.html#StyleElement
  11. *
  12. * @author Betsy Dupuis
  13. *
  14. * @type {import('../lib/types').Plugin<void>}
  15. */
  16. exports.fn = () => {
  17. return {
  18. element: {
  19. enter: (node, parentNode) => {
  20. if (node.name === 'style') {
  21. detachNodeFromParent(node, parentNode);
  22. }
  23. },
  24. },
  25. };
  26. };