postcss-discard-comments 7.0.5 → 7.0.6
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/lib/commentParser.js +9 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-discard-comments",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.6",
|
|
4
4
|
"description": "Discard comments in your CSS files with PostCSS.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"repository": "cssnano/cssnano",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"postcss-selector-parser": "^7.1.
|
|
27
|
+
"postcss-selector-parser": "^7.1.1"
|
|
28
28
|
},
|
|
29
29
|
"bugs": {
|
|
30
30
|
"url": "https://github.com/cssnano/cssnano/issues"
|
package/src/lib/commentParser.js
CHANGED
|
@@ -20,15 +20,15 @@ module.exports = function commentParser(input) {
|
|
|
20
20
|
const tokens = [];
|
|
21
21
|
const length = input.length;
|
|
22
22
|
let pos = 0;
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
let state = STATES.NORMAL;
|
|
25
25
|
let tokenStart = 0;
|
|
26
26
|
let commentStart = 0;
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
while (pos < length) {
|
|
29
29
|
const char = input[pos];
|
|
30
30
|
const nextChar = pos + 1 < length ? input[pos + 1] : '';
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
switch (state) {
|
|
33
33
|
case STATES.NORMAL:
|
|
34
34
|
if (char === '/' && nextChar === '*') {
|
|
@@ -46,7 +46,7 @@ module.exports = function commentParser(input) {
|
|
|
46
46
|
state = STATES.IN_SINGLE_QUOTE;
|
|
47
47
|
}
|
|
48
48
|
break;
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
case STATES.IN_SINGLE_QUOTE:
|
|
51
51
|
if (char === '\\' && nextChar) {
|
|
52
52
|
// Skip escaped character
|
|
@@ -56,7 +56,7 @@ module.exports = function commentParser(input) {
|
|
|
56
56
|
state = STATES.NORMAL;
|
|
57
57
|
}
|
|
58
58
|
break;
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
case STATES.IN_DOUBLE_QUOTE:
|
|
61
61
|
if (char === '\\' && nextChar) {
|
|
62
62
|
// Skip escaped character
|
|
@@ -66,7 +66,7 @@ module.exports = function commentParser(input) {
|
|
|
66
66
|
state = STATES.NORMAL;
|
|
67
67
|
}
|
|
68
68
|
break;
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
case STATES.IN_COMMENT:
|
|
71
71
|
if (char === '*' && nextChar === '/') {
|
|
72
72
|
// Found comment end
|
|
@@ -78,10 +78,10 @@ module.exports = function commentParser(input) {
|
|
|
78
78
|
}
|
|
79
79
|
break;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
pos++;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
// Handle remaining content
|
|
86
86
|
if (state === STATES.IN_COMMENT) {
|
|
87
87
|
// Unclosed comment - treat as comment to end
|
|
@@ -90,6 +90,6 @@ module.exports = function commentParser(input) {
|
|
|
90
90
|
// Add final non-comment token
|
|
91
91
|
tokens.push([0, tokenStart, length]);
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
return tokens;
|
|
95
95
|
};
|