source: trip-planner-front/node_modules/svgo/plugins/removeEmptyAttrs.js@ eed0bf8

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

initial commit

  • Property mode set to 100644
File size: 776 bytes
Line 
1'use strict';
2
3const { attrsGroups } = require('./_collections.js');
4
5exports.name = 'removeEmptyAttrs';
6
7exports.type = 'perItem';
8
9exports.active = true;
10
11exports.description = 'removes empty attributes';
12
13/**
14 * Remove attributes with empty values.
15 *
16 * @param {Object} item current iteration item
17 * @return {Boolean} if false, item will be filtered out
18 *
19 * @author Kir Belevich
20 */
21exports.fn = function (item) {
22 if (item.type === 'element') {
23 for (const [name, value] of Object.entries(item.attributes)) {
24 if (
25 value === '' &&
26 // empty conditional processing attributes prevents elements from rendering
27 attrsGroups.conditionalProcessing.includes(name) === false
28 ) {
29 delete item.attributes[name];
30 }
31 }
32 }
33};
Note: See TracBrowser for help on using the repository browser.