source: trip-planner-front/node_modules/svgo/plugins/removeNonInheritableGroupAttrs.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 925 bytes
Line 
1'use strict';
2
3exports.name = 'removeNonInheritableGroupAttrs';
4
5exports.type = 'perItem';
6
7exports.active = true;
8
9exports.description =
10 'removes non-inheritable group’s presentational attributes';
11
12const {
13 inheritableAttrs,
14 attrsGroups,
15 presentationNonInheritableGroupAttrs,
16} = require('./_collections');
17
18/**
19 * Remove non-inheritable group's "presentation" attributes.
20 *
21 * @param {Object} item current iteration item
22 * @return {Boolean} if false, item will be filtered out
23 *
24 * @author Kir Belevich
25 */
26exports.fn = function (item) {
27 if (item.type === 'element' && item.name === 'g') {
28 for (const name of Object.keys(item.attributes)) {
29 if (
30 attrsGroups.presentation.includes(name) === true &&
31 inheritableAttrs.includes(name) === false &&
32 presentationNonInheritableGroupAttrs.includes(name) === false
33 ) {
34 delete item.attributes[name];
35 }
36 }
37 }
38};
Note: See TracBrowser for help on using the repository browser.