postcss-normalize-charset 8.0.3 → 8.0.5
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/package.json +2 -2
- package/src/index.js +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-normalize-charset",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.5",
|
|
4
4
|
"description": "Add necessary or remove extra charset with PostCSS",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"repository": {
|
|
29
29
|
"type": "git",
|
|
30
|
-
"url": "cssnano/cssnano"
|
|
30
|
+
"url": "git+https://github.com/cssnano/cssnano.git"
|
|
31
31
|
},
|
|
32
32
|
"bugs": {
|
|
33
33
|
"url": "https://github.com/cssnano/cssnano/issues"
|
package/src/index.js
CHANGED
|
@@ -23,11 +23,16 @@ function pluginCreator(opts = {}) {
|
|
|
23
23
|
let charsetRule;
|
|
24
24
|
/** @type {import('postcss').Node | undefined} */
|
|
25
25
|
let nonAsciiNode;
|
|
26
|
+
/** @type {string | undefined} */
|
|
27
|
+
let charsetSeparator;
|
|
26
28
|
|
|
27
29
|
css.walk((node) => {
|
|
28
30
|
if (node.type === 'atrule' && node.name === charset) {
|
|
29
31
|
if (!charsetRule) {
|
|
30
32
|
charsetRule = node;
|
|
33
|
+
if (node === css.first) {
|
|
34
|
+
charsetSeparator = node.next()?.raws.before;
|
|
35
|
+
}
|
|
31
36
|
}
|
|
32
37
|
node.remove();
|
|
33
38
|
} else if (
|
|
@@ -49,6 +54,10 @@ function pluginCreator(opts = {}) {
|
|
|
49
54
|
if (charsetRule) {
|
|
50
55
|
charsetRule.source = nonAsciiNode.source;
|
|
51
56
|
css.prepend(charsetRule);
|
|
57
|
+
const nextNode = charsetRule.next();
|
|
58
|
+
if (charsetSeparator !== undefined && nextNode) {
|
|
59
|
+
nextNode.raws.before = charsetSeparator;
|
|
60
|
+
}
|
|
52
61
|
}
|
|
53
62
|
}
|
|
54
63
|
},
|