@cyberalien/svg-utils 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/svg/ids.js +12 -5
  2. package/package.json +1 -1
package/lib/svg/ids.js CHANGED
@@ -114,14 +114,21 @@ function changeSVGIDs(root, callback) {
114
114
  * Remove duplicate IDs from SVG
115
115
  */
116
116
  function removeDuplicateIDs(root, data) {
117
- const remove = [];
117
+ const remove = /* @__PURE__ */ new Set();
118
118
  for (const id in data) {
119
119
  const nodes = data[id];
120
- if (nodes.length > 1) remove.push(...nodes.slice(1));
120
+ if (nodes.length > 1) remove.add(id);
121
+ }
122
+ if (remove.size) {
123
+ const removing = /* @__PURE__ */ new Set();
124
+ return iterateXMLContent(root, (node) => {
125
+ if (node.type !== "tag") return;
126
+ const id = node.attribs.id;
127
+ if (typeof id !== "string" || !remove.has(id)) return;
128
+ if (removing.has(id)) return "remove";
129
+ removing.add(id);
130
+ });
121
131
  }
122
- if (remove.length) return iterateXMLContent(root, (node) => {
123
- if (remove.includes(node)) return "remove";
124
- });
125
132
  return root;
126
133
  }
127
134
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "description": "Common functions for working with SVG used by various packages.",
5
5
  "author": "Vjacheslav Trushkin",
6
- "version": "0.0.9",
6
+ "version": "0.0.10",
7
7
  "license": "MIT",
8
8
  "bugs": "https://github.com/cyberalien/svg-utils/issues",
9
9
  "homepage": "https://cyberalien.dev/",