@unocss/preset-icons 0.48.2 → 0.48.3

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.
package/dist/browser.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const cdn = require('./shared/preset-icons.cfc75ae5.cjs');
5
+ const cdn = require('./shared/preset-icons.a2373a72.cjs');
6
6
  const core = require('./core.cjs');
7
7
  require('ohmyfetch');
8
8
  require('@unocss/core');
package/dist/browser.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.21b4ba57.mjs';
1
+ import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.b607b543.mjs';
2
2
  import { createPresetIcons } from './core.mjs';
3
3
  export { combineLoaders, createPresetIcons } from './core.mjs';
4
4
  import 'ohmyfetch';
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const cdn = require('./shared/preset-icons.cfc75ae5.cjs');
5
+ const cdn = require('./shared/preset-icons.a2373a72.cjs');
6
6
  const core = require('./core.cjs');
7
7
  require('ohmyfetch');
8
8
  require('@unocss/core');
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.21b4ba57.mjs';
1
+ import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.b607b543.mjs';
2
2
  import { createPresetIcons, combineLoaders } from './core.mjs';
3
3
  export { combineLoaders, createPresetIcons } from './core.mjs';
4
4
  import 'ohmyfetch';
@@ -445,6 +445,7 @@ add("yellowgreen", [154, 205, 50]);
445
445
 
446
446
  const svgWidthRegex = /width\s*=\s*["'](\w+)["']/;
447
447
  const svgHeightRegex = /height\s*=\s*["'](\w+)["']/;
448
+ const svgTagRegex = /<svg\s+/;
448
449
  function configureSvgSize(svg, props, scale) {
449
450
  const svgNode = svg.slice(0, svg.indexOf(">"));
450
451
  let result = svgWidthRegex.exec(svgNode);
@@ -480,10 +481,10 @@ async function mergeIconProps(svg, collection, icon, options, propsProvider, aft
480
481
  afterCustomizations?.(props);
481
482
  const [widthOnSvg, heightOnSvg] = configureSvgSize(svg, props, scale);
482
483
  if (addXmlNs) {
483
- if (!svg.includes(" xmlns=") && !props["xmlns"]) {
484
+ if (!svg.includes("xmlns=") && !props["xmlns"]) {
484
485
  props["xmlns"] = "http://www.w3.org/2000/svg";
485
486
  }
486
- if (!svg.includes(" xmlns:xlink=") && svg.includes("xlink:") && !props["xmlns:xlink"]) {
487
+ if (!svg.includes("xmlns:xlink=") && svg.includes("xlink:") && !props["xmlns:xlink"]) {
487
488
  props["xmlns:xlink"] = "http://www.w3.org/1999/xlink";
488
489
  }
489
490
  }
@@ -491,15 +492,15 @@ async function mergeIconProps(svg, collection, icon, options, propsProvider, aft
491
492
  (p) => p === "width" && widthOnSvg || p === "height" && heightOnSvg ? null : `${p}="${props[p]}"`
492
493
  ).filter((p) => p != null);
493
494
  if (propsToAdd.length) {
494
- svg = svg.replace("<svg ", `<svg ${propsToAdd.join(" ")} `);
495
+ svg = svg.replace(svgTagRegex, `<svg ${propsToAdd.join(" ")} `);
495
496
  }
496
497
  if (options) {
497
498
  const { defaultStyle, defaultClass } = options;
498
- if (defaultClass && !svg.includes(" class=")) {
499
- svg = svg.replace("<svg ", `<svg class="${defaultClass}" `);
499
+ if (defaultClass && !svg.includes("class=")) {
500
+ svg = svg.replace(svgTagRegex, `<svg class="${defaultClass}" `);
500
501
  }
501
- if (defaultStyle && !svg.includes(" style=")) {
502
- svg = svg.replace("<svg ", `<svg style="${defaultStyle}" `);
502
+ if (defaultStyle && !svg.includes("style=")) {
503
+ svg = svg.replace(svgTagRegex, `<svg style="${defaultStyle}" `);
503
504
  }
504
505
  }
505
506
  const usedProps = options?.usedProps;
@@ -443,6 +443,7 @@ add("yellowgreen", [154, 205, 50]);
443
443
 
444
444
  const svgWidthRegex = /width\s*=\s*["'](\w+)["']/;
445
445
  const svgHeightRegex = /height\s*=\s*["'](\w+)["']/;
446
+ const svgTagRegex = /<svg\s+/;
446
447
  function configureSvgSize(svg, props, scale) {
447
448
  const svgNode = svg.slice(0, svg.indexOf(">"));
448
449
  let result = svgWidthRegex.exec(svgNode);
@@ -478,10 +479,10 @@ async function mergeIconProps(svg, collection, icon, options, propsProvider, aft
478
479
  afterCustomizations?.(props);
479
480
  const [widthOnSvg, heightOnSvg] = configureSvgSize(svg, props, scale);
480
481
  if (addXmlNs) {
481
- if (!svg.includes(" xmlns=") && !props["xmlns"]) {
482
+ if (!svg.includes("xmlns=") && !props["xmlns"]) {
482
483
  props["xmlns"] = "http://www.w3.org/2000/svg";
483
484
  }
484
- if (!svg.includes(" xmlns:xlink=") && svg.includes("xlink:") && !props["xmlns:xlink"]) {
485
+ if (!svg.includes("xmlns:xlink=") && svg.includes("xlink:") && !props["xmlns:xlink"]) {
485
486
  props["xmlns:xlink"] = "http://www.w3.org/1999/xlink";
486
487
  }
487
488
  }
@@ -489,15 +490,15 @@ async function mergeIconProps(svg, collection, icon, options, propsProvider, aft
489
490
  (p) => p === "width" && widthOnSvg || p === "height" && heightOnSvg ? null : `${p}="${props[p]}"`
490
491
  ).filter((p) => p != null);
491
492
  if (propsToAdd.length) {
492
- svg = svg.replace("<svg ", `<svg ${propsToAdd.join(" ")} `);
493
+ svg = svg.replace(svgTagRegex, `<svg ${propsToAdd.join(" ")} `);
493
494
  }
494
495
  if (options) {
495
496
  const { defaultStyle, defaultClass } = options;
496
- if (defaultClass && !svg.includes(" class=")) {
497
- svg = svg.replace("<svg ", `<svg class="${defaultClass}" `);
497
+ if (defaultClass && !svg.includes("class=")) {
498
+ svg = svg.replace(svgTagRegex, `<svg class="${defaultClass}" `);
498
499
  }
499
- if (defaultStyle && !svg.includes(" style=")) {
500
- svg = svg.replace("<svg ", `<svg style="${defaultStyle}" `);
500
+ if (defaultStyle && !svg.includes("style=")) {
501
+ svg = svg.replace(svgTagRegex, `<svg style="${defaultStyle}" `);
501
502
  }
502
503
  }
503
504
  const usedProps = options?.usedProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-icons",
3
- "version": "0.48.2",
3
+ "version": "0.48.3",
4
4
  "description": "Pure CSS Icons for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -47,8 +47,8 @@
47
47
  "*.css"
48
48
  ],
49
49
  "dependencies": {
50
- "@iconify/utils": "^2.0.9",
51
- "@unocss/core": "0.48.2",
50
+ "@iconify/utils": "^2.0.10",
51
+ "@unocss/core": "0.48.3",
52
52
  "ohmyfetch": "^0.4.21"
53
53
  },
54
54
  "devDependencies": {