summaryrefslogtreecommitdiff
path: root/node_modules/svgo/plugins/removeXMLProcInst.js
blob: 73ec2335e79b7f612cfd45880c988d18b5cdef11 (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
28
'use strict';

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

exports.name = 'removeXMLProcInst';
exports.description = 'removes XML processing instructions';

/**
 * Remove XML Processing Instruction.
 *
 * @example
 * <?xml version="1.0" encoding="utf-8"?>
 *
 * @author Kir Belevich
 *
 * @type {import('./plugins-types').Plugin<'removeXMLProcInst'>}
 */
exports.fn = () => {
  return {
    instruction: {
      enter: (node, parentNode) => {
        if (node.name === 'xml') {
          detachNodeFromParent(node, parentNode);
        }
      },
    },
  };
};