1
0
mirror of https://github.com/svg/svgo.git synced 2025-04-27 00:08:49 +03:00
svgo/plugins/removeScriptElement.js
Bogdan Chadkin f00bd727b0
Refactor basic plugins with visitor api (#1518)
- cleanupAttrs
- convertEllipseToCircle
- removeDesc
- removeDoctype
- removeEmptyText
- removeMetadata
- removeRasterImages
- removeScriptElement
- removeStyleElement
- removeTitle
- removeXMLProcInst
2021-08-12 14:57:36 +03:00

28 lines
516 B
JavaScript

'use strict';
const { detachNodeFromParent } = require('../lib/xast.js');
exports.type = 'visitor';
exports.active = false;
exports.description = 'removes <script> elements (disabled by default)';
/**
* Remove <script>.
*
* https://www.w3.org/TR/SVG11/script.html
*
*
* @author Patrick Klingemann
*/
exports.fn = () => {
return {
element: {
enter: (node, parentNode) => {
if (node.name === 'script') {
detachNodeFromParent(node, parentNode);
}
},
},
};
};