postcss 8.5.13 → 8.5.15
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/lib/parser.js +36 -29
- package/lib/processor.js +1 -1
- package/lib/stringifier.js +7 -28
- package/package.json +2 -2
package/lib/parser.js
CHANGED
|
@@ -20,6 +20,12 @@ function findLastWithPosition(tokens) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
function tokensToString(tokens, from, to) {
|
|
24
|
+
let result = ''
|
|
25
|
+
for (let i = from; i < to; i++) result += tokens[i][1]
|
|
26
|
+
return result
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
class Parser {
|
|
24
30
|
constructor(input) {
|
|
25
31
|
this.input = input
|
|
@@ -132,9 +138,10 @@ class Parser {
|
|
|
132
138
|
if (founded === 2) break
|
|
133
139
|
}
|
|
134
140
|
}
|
|
135
|
-
// If the token is a word, e.g. `!important`, `red` or any other valid
|
|
136
|
-
// Then we need to return the colon after that word
|
|
137
|
-
//
|
|
141
|
+
// If the token is a word, e.g. `!important`, `red` or any other valid
|
|
142
|
+
// property's value. Then we need to return the colon after that word
|
|
143
|
+
// token. [3] is the "end" colon of that word. And because we need it
|
|
144
|
+
// after that one we do +1 to get the next one.
|
|
138
145
|
throw this.input.error(
|
|
139
146
|
'Missed semicolon',
|
|
140
147
|
token[0] === 'word' ? token[3] + 1 : token[2]
|
|
@@ -207,50 +214,50 @@ class Parser {
|
|
|
207
214
|
)
|
|
208
215
|
node.source.end.offset++
|
|
209
216
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
217
|
+
let start = 0
|
|
218
|
+
while (tokens[start][0] !== 'word') {
|
|
219
|
+
if (start === tokens.length - 1) this.unknownWord([tokens[start]])
|
|
220
|
+
start++
|
|
213
221
|
}
|
|
214
|
-
node.
|
|
222
|
+
node.raws.before += tokensToString(tokens, 0, start)
|
|
223
|
+
node.source.start = this.getPosition(tokens[start][2])
|
|
215
224
|
|
|
216
|
-
|
|
217
|
-
while (tokens.length) {
|
|
218
|
-
let type = tokens[
|
|
225
|
+
let propStart = start
|
|
226
|
+
while (start < tokens.length) {
|
|
227
|
+
let type = tokens[start][0]
|
|
219
228
|
if (type === ':' || type === 'space' || type === 'comment') {
|
|
220
229
|
break
|
|
221
230
|
}
|
|
222
|
-
|
|
231
|
+
start++
|
|
223
232
|
}
|
|
233
|
+
node.prop = tokensToString(tokens, propStart, start)
|
|
224
234
|
|
|
225
|
-
|
|
226
|
-
|
|
235
|
+
let betweenStart = start
|
|
227
236
|
let token
|
|
228
|
-
while (tokens.length) {
|
|
229
|
-
token = tokens
|
|
230
|
-
|
|
231
|
-
if (token[0] === ':')
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
} else {
|
|
235
|
-
if (token[0] === 'word' && /\w/.test(token[1])) {
|
|
236
|
-
this.unknownWord([token])
|
|
237
|
-
}
|
|
238
|
-
node.raws.between += token[1]
|
|
237
|
+
while (start < tokens.length) {
|
|
238
|
+
token = tokens[start]
|
|
239
|
+
start++
|
|
240
|
+
if (token[0] === ':') break
|
|
241
|
+
if (token[0] === 'word' && /\w/.test(token[1])) {
|
|
242
|
+
this.unknownWord([token])
|
|
239
243
|
}
|
|
240
244
|
}
|
|
245
|
+
node.raws.between = tokensToString(tokens, betweenStart, start)
|
|
241
246
|
|
|
242
247
|
if (node.prop[0] === '_' || node.prop[0] === '*') {
|
|
243
248
|
node.raws.before += node.prop[0]
|
|
244
249
|
node.prop = node.prop.slice(1)
|
|
245
250
|
}
|
|
246
251
|
|
|
247
|
-
let
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
next = tokens[0][0]
|
|
252
|
+
let firstSpacesStart = start
|
|
253
|
+
while (start < tokens.length) {
|
|
254
|
+
let next = tokens[start][0]
|
|
251
255
|
if (next !== 'space' && next !== 'comment') break
|
|
252
|
-
|
|
256
|
+
start++
|
|
253
257
|
}
|
|
258
|
+
let firstSpaces = tokens.slice(firstSpacesStart, start)
|
|
259
|
+
|
|
260
|
+
tokens = tokens.slice(start)
|
|
254
261
|
|
|
255
262
|
this.precheckMissedSemicolon(tokens)
|
|
256
263
|
|
package/lib/processor.js
CHANGED
package/lib/stringifier.js
CHANGED
|
@@ -85,23 +85,15 @@ class Stringifier {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
block(node, start) {
|
|
88
|
-
let
|
|
89
|
-
let between =
|
|
90
|
-
typeof raws.between !== 'undefined'
|
|
91
|
-
? raws.between
|
|
92
|
-
: this.raw(node, 'between', 'beforeOpen')
|
|
88
|
+
let between = this.raw(node, 'between', 'beforeOpen')
|
|
93
89
|
this.builder(escapeHTMLInCSS(start + between) + '{', node, 'start')
|
|
94
90
|
|
|
95
91
|
let after
|
|
96
92
|
if (node.nodes && node.nodes.length) {
|
|
97
93
|
this.body(node)
|
|
98
|
-
after =
|
|
99
|
-
typeof raws.after !== 'undefined' ? raws.after : this.raw(node, 'after')
|
|
94
|
+
after = this.raw(node, 'after')
|
|
100
95
|
} else {
|
|
101
|
-
after =
|
|
102
|
-
typeof raws.after !== 'undefined'
|
|
103
|
-
? raws.after
|
|
104
|
-
: this.raw(node, 'after', 'emptyBody')
|
|
96
|
+
after = this.raw(node, 'after', 'emptyBody')
|
|
105
97
|
}
|
|
106
98
|
|
|
107
99
|
if (after) this.builder(escapeHTMLInCSS(after))
|
|
@@ -120,34 +112,21 @@ class Stringifier {
|
|
|
120
112
|
let isDocument = node.type === 'document'
|
|
121
113
|
for (let i = 0; i < nodes.length; i++) {
|
|
122
114
|
let child = nodes[i]
|
|
123
|
-
let before = child
|
|
124
|
-
if (typeof before === 'undefined') {
|
|
125
|
-
before = this.raw(child, 'before')
|
|
126
|
-
}
|
|
115
|
+
let before = this.raw(child, 'before')
|
|
127
116
|
if (before) this.builder(isDocument ? before : escapeHTMLInCSS(before))
|
|
128
117
|
this.stringify(child, last !== i || semicolon)
|
|
129
118
|
}
|
|
130
119
|
}
|
|
131
120
|
|
|
132
121
|
comment(node) {
|
|
133
|
-
let
|
|
134
|
-
let
|
|
135
|
-
typeof raws.left !== 'undefined'
|
|
136
|
-
? raws.left
|
|
137
|
-
: this.raw(node, 'left', 'commentLeft')
|
|
138
|
-
let right =
|
|
139
|
-
typeof raws.right !== 'undefined'
|
|
140
|
-
? raws.right
|
|
141
|
-
: this.raw(node, 'right', 'commentRight')
|
|
122
|
+
let left = this.raw(node, 'left', 'commentLeft')
|
|
123
|
+
let right = this.raw(node, 'right', 'commentRight')
|
|
142
124
|
this.builder(escapeHTMLInCSS('/*' + left + node.text + right + '*/'), node)
|
|
143
125
|
}
|
|
144
126
|
|
|
145
127
|
decl(node, semicolon) {
|
|
146
128
|
let raws = node.raws
|
|
147
|
-
let between =
|
|
148
|
-
typeof raws.between !== 'undefined'
|
|
149
|
-
? raws.between
|
|
150
|
-
: this.raw(node, 'between', 'colon')
|
|
129
|
+
let between = this.raw(node, 'between', 'colon')
|
|
151
130
|
|
|
152
131
|
let string = node.prop + between + this.rawValue(node, 'value')
|
|
153
132
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss",
|
|
3
|
-
"version": "8.5.
|
|
3
|
+
"version": "8.5.15",
|
|
4
4
|
"description": "Tool for transforming styles with JS plugins",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"./package.json": "./package.json"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"nanoid": "^3.3.
|
|
81
|
+
"nanoid": "^3.3.12",
|
|
82
82
|
"picocolors": "^1.1.1",
|
|
83
83
|
"source-map-js": "^1.2.1"
|
|
84
84
|
},
|