summaryrefslogtreecommitdiff
path: root/node_modules/svgo/plugins/removeStyleElement.js
blob: d869a50ac0d4bda7ed41248404ea7fbeb7bc71ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';

const { detachNodeFromParent } = require('../lib/xast.js');

exports.name = 'removeStyleElement';
exports.description = 'removes <style> element (disabled by default)';

/**
 * Remove <style>.
 *
 * https://www.w3.org/TR/SVG11/styling.html#StyleElement
 *
 * @author Betsy Dupuis
 *
 * @type {import('./plugins-types').Plugin<'removeStyleElement'>}
 */
exports.fn = () => {
  return {
    element: {
      enter: (node, parentNode) => {
        if (node.name === 'style') {
          detachNodeFromParent(node, parentNode);
        }
      },
    },
  };
};