1
0
mirror of https://github.com/svg/svgo.git synced 2025-04-19 10:22:15 +03:00
svgo/plugins/removeComments.js
Bogdan Chadkin 9b8f13e911
Add plugin types (#1527)
Covered following plugins
- addAttributesToSVGElement.js 
- addClassesToSVGElement.js 
- cleanupAttrs.js 
- convertEllipseToCircle.js 
- removeAttributesBySelector.js 
- removeAttrs.js 
- removeComments.js 
- removeDesc.js 
- removeDoctype.js 
- removeElementsByAttr.js 
- removeEmptyText.js 
- removeMetadata.js 
- removeRasterImages.js 
- removeScriptElement.js 
- removeStyleElement.js 
- removeTitle.js 
- removeXMLProcInst.js
2021-08-15 13:52:41 +03:00

32 lines
634 B
JavaScript

'use strict';
const { detachNodeFromParent } = require('../lib/xast.js');
exports.name = 'removeComments';
exports.type = 'visitor';
exports.active = true;
exports.description = 'removes comments';
/**
* Remove comments.
*
* @example
* <!-- Generator: Adobe Illustrator 15.0.0, SVG Export
* Plug-In . SVG Version: 6.00 Build 0) -->
*
* @author Kir Belevich
*
* @type {import('../lib/types').Plugin<void>}
*/
exports.fn = () => {
return {
comment: {
enter: (node, parentNode) => {
if (node.value.charAt(0) !== '!') {
detachNodeFromParent(node, parentNode);
}
},
},
};
};