@iconify/tools 3.0.0-beta.2 → 3.0.0-beta.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.
|
@@ -9,6 +9,27 @@ require('../../css/parser/strings.cjs');
|
|
|
9
9
|
require('../../css/parser/text.cjs');
|
|
10
10
|
require('../data/tags.cjs');
|
|
11
11
|
|
|
12
|
+
const allowedStyleRules = /* @__PURE__ */ new Set([
|
|
13
|
+
// Animations
|
|
14
|
+
"animation",
|
|
15
|
+
"animation*",
|
|
16
|
+
"offset",
|
|
17
|
+
"offset*",
|
|
18
|
+
// Transformations
|
|
19
|
+
"transform",
|
|
20
|
+
"transform*",
|
|
21
|
+
"translate",
|
|
22
|
+
// Transitions
|
|
23
|
+
"transition",
|
|
24
|
+
"transition*"
|
|
25
|
+
]);
|
|
26
|
+
const knownIgnoredRules = /* @__PURE__ */ new Set([
|
|
27
|
+
// Illustrator / Inkscape junk
|
|
28
|
+
"solid*",
|
|
29
|
+
"paint*",
|
|
30
|
+
"color-interpolation-filters",
|
|
31
|
+
"stop-opacity"
|
|
32
|
+
]);
|
|
12
33
|
function cleanupInlineStyle(svg) {
|
|
13
34
|
svg_parse.parseSVGSync(svg, (item) => {
|
|
14
35
|
const $element = item.$element;
|
|
@@ -35,7 +56,8 @@ function cleanupInlineStyle(svg) {
|
|
|
35
56
|
$element.attr(prop, value);
|
|
36
57
|
return;
|
|
37
58
|
}
|
|
38
|
-
|
|
59
|
+
const partial = prop.split("-").shift() + "*";
|
|
60
|
+
if (svg_data_attributes.tagSpecificInlineStyles[tagName]?.has(prop) || allowedStyleRules.has(prop) || allowedStyleRules.has(partial)) {
|
|
39
61
|
newStyle[prop] = value;
|
|
40
62
|
return;
|
|
41
63
|
}
|
|
@@ -49,7 +71,7 @@ function cleanupInlineStyle(svg) {
|
|
|
49
71
|
}
|
|
50
72
|
if (svg_data_attributes.badSoftwareAttributes.has(prop) || svg_data_attributes.badAttributePrefixes.has(
|
|
51
73
|
prop.split("-").shift()
|
|
52
|
-
)) {
|
|
74
|
+
) || knownIgnoredRules.has(prop) || knownIgnoredRules.has(partial)) {
|
|
53
75
|
return;
|
|
54
76
|
}
|
|
55
77
|
if (prop.slice(0, 1) === "-") {
|
|
@@ -7,6 +7,27 @@ import '../../css/parser/strings.mjs';
|
|
|
7
7
|
import '../../css/parser/text.mjs';
|
|
8
8
|
import '../data/tags.mjs';
|
|
9
9
|
|
|
10
|
+
const allowedStyleRules = /* @__PURE__ */ new Set([
|
|
11
|
+
// Animations
|
|
12
|
+
"animation",
|
|
13
|
+
"animation*",
|
|
14
|
+
"offset",
|
|
15
|
+
"offset*",
|
|
16
|
+
// Transformations
|
|
17
|
+
"transform",
|
|
18
|
+
"transform*",
|
|
19
|
+
"translate",
|
|
20
|
+
// Transitions
|
|
21
|
+
"transition",
|
|
22
|
+
"transition*"
|
|
23
|
+
]);
|
|
24
|
+
const knownIgnoredRules = /* @__PURE__ */ new Set([
|
|
25
|
+
// Illustrator / Inkscape junk
|
|
26
|
+
"solid*",
|
|
27
|
+
"paint*",
|
|
28
|
+
"color-interpolation-filters",
|
|
29
|
+
"stop-opacity"
|
|
30
|
+
]);
|
|
10
31
|
function cleanupInlineStyle(svg) {
|
|
11
32
|
parseSVGSync(svg, (item) => {
|
|
12
33
|
const $element = item.$element;
|
|
@@ -33,7 +54,8 @@ function cleanupInlineStyle(svg) {
|
|
|
33
54
|
$element.attr(prop, value);
|
|
34
55
|
return;
|
|
35
56
|
}
|
|
36
|
-
|
|
57
|
+
const partial = prop.split("-").shift() + "*";
|
|
58
|
+
if (tagSpecificInlineStyles[tagName]?.has(prop) || allowedStyleRules.has(prop) || allowedStyleRules.has(partial)) {
|
|
37
59
|
newStyle[prop] = value;
|
|
38
60
|
return;
|
|
39
61
|
}
|
|
@@ -47,7 +69,7 @@ function cleanupInlineStyle(svg) {
|
|
|
47
69
|
}
|
|
48
70
|
if (badSoftwareAttributes.has(prop) || badAttributePrefixes.has(
|
|
49
71
|
prop.split("-").shift()
|
|
50
|
-
)) {
|
|
72
|
+
) || knownIgnoredRules.has(prop) || knownIgnoredRules.has(partial)) {
|
|
51
73
|
return;
|
|
52
74
|
}
|
|
53
75
|
if (prop.slice(0, 1) === "-") {
|
|
@@ -19,9 +19,6 @@ function cleanupRootStyle(svg) {
|
|
|
19
19
|
case "global":
|
|
20
20
|
return item.value;
|
|
21
21
|
case "at-rule":
|
|
22
|
-
if (item.prop === "supports") {
|
|
23
|
-
return item.value;
|
|
24
|
-
}
|
|
25
22
|
(result.removedAtRules || (result.removedAtRules = /* @__PURE__ */ new Set())).add(item.prop);
|
|
26
23
|
return;
|
|
27
24
|
case "keyframes":
|
|
@@ -17,9 +17,6 @@ function cleanupRootStyle(svg) {
|
|
|
17
17
|
case "global":
|
|
18
18
|
return item.value;
|
|
19
19
|
case "at-rule":
|
|
20
|
-
if (item.prop === "supports") {
|
|
21
|
-
return item.value;
|
|
22
|
-
}
|
|
23
20
|
(result.removedAtRules || (result.removedAtRules = /* @__PURE__ */ new Set())).add(item.prop);
|
|
24
21
|
return;
|
|
25
22
|
case "keyframes":
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
|
|
5
5
|
"author": "Vjacheslav Trushkin",
|
|
6
|
-
"version": "3.0.0-beta.
|
|
6
|
+
"version": "3.0.0-beta.3",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"bugs": "https://github.com/iconify/tools/issues",
|
|
9
9
|
"homepage": "https://github.com/iconify/tools",
|