- Timestamp:
- 11/25/21 22:08:24 (3 years ago)
- Branches:
- master
- Children:
- 8d391a1
- Parents:
- 59329aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/node_modules/svgo/plugins/removeEmptyAttrs.js
r59329aa re29cc2e 3 3 const { attrsGroups } = require('./_collections.js'); 4 4 5 exports.type = 'visitor'; 5 6 exports.name = 'removeEmptyAttrs'; 6 7 exports.type = 'perItem';8 9 7 exports.active = true; 10 11 8 exports.description = 'removes empty attributes'; 12 9 … … 14 11 * Remove attributes with empty values. 15 12 * 16 * @param {Object} item current iteration item 17 * @return {Boolean} if false, item will be filtered out 13 * @author Kir Belevich 18 14 * 19 * @ author Kir Belevich15 * @type {import('../lib/types').Plugin<void>} 20 16 */ 21 exports.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 } 17 exports.fn = () => { 18 return { 19 element: { 20 enter: (node) => { 21 for (const [name, value] of Object.entries(node.attributes)) { 22 if ( 23 value === '' && 24 // empty conditional processing attributes prevents elements from rendering 25 attrsGroups.conditionalProcessing.includes(name) === false 26 ) { 27 delete node.attributes[name]; 28 } 29 } 30 }, 31 }, 32 }; 33 33 };
Note:
See TracChangeset
for help on using the changeset viewer.