summaryrefslogtreecommitdiff
path: root/node_modules/svgo/plugins/removeEmptyAttrs.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/svgo/plugins/removeEmptyAttrs.js')
-rw-r--r--node_modules/svgo/plugins/removeEmptyAttrs.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/node_modules/svgo/plugins/removeEmptyAttrs.js b/node_modules/svgo/plugins/removeEmptyAttrs.js
new file mode 100644
index 00000000..83f567c3
--- /dev/null
+++ b/node_modules/svgo/plugins/removeEmptyAttrs.js
@@ -0,0 +1,31 @@
+'use strict';
+
+const { attrsGroups } = require('./_collections.js');
+
+exports.name = 'removeEmptyAttrs';
+exports.description = 'removes empty attributes';
+
+/**
+ * Remove attributes with empty values.
+ *
+ * @author Kir Belevich
+ *
+ * @type {import('./plugins-types').Plugin<'removeEmptyAttrs'>}
+ */
+exports.fn = () => {
+ return {
+ element: {
+ enter: (node) => {
+ for (const [name, value] of Object.entries(node.attributes)) {
+ if (
+ value === '' &&
+ // empty conditional processing attributes prevents elements from rendering
+ attrsGroups.conditionalProcessing.includes(name) === false
+ ) {
+ delete node.attributes[name];
+ }
+ }
+ },
+ },
+ };
+};