postcss 8.4.2 → 8.4.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.

Potentially problematic release.


This version of postcss might be problematic. Click here for more details.

package/lib/at-rule.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import Container, { ContainerProps } from './container.js'
2
2
 
3
- interface AtRuleRaws {
3
+ interface AtRuleRaws extends Record<string, unknown> {
4
4
  /**
5
5
  * The space symbols before the node. It also stores `*`
6
6
  * and `_` symbols before the declaration (IE hack).
package/lib/comment.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import Container from './container.js'
2
2
  import Node, { NodeProps } from './node.js'
3
3
 
4
- interface CommentRaws {
4
+ interface CommentRaws extends Record<string, unknown> {
5
5
  /**
6
6
  * The space symbols before the node.
7
7
  */
@@ -1,7 +1,7 @@
1
1
  import Container from './container.js'
2
2
  import Node from './node.js'
3
3
 
4
- interface DeclarationRaws {
4
+ interface DeclarationRaws extends Record<string, unknown> {
5
5
  /**
6
6
  * The space symbols before the node. It also stores `*`
7
7
  * and `_` symbols before the declaration (IE hack).
@@ -84,7 +84,7 @@ class MapGenerator {
84
84
  this.root.removeChild(i)
85
85
  }
86
86
  }
87
- } else {
87
+ } else if (this.css) {
88
88
  this.css = this.css.replace(/(\n)?\/\*#[\S\s]*?\*\/$/gm, '')
89
89
  }
90
90
  }
@@ -104,7 +104,7 @@ class MapGenerator {
104
104
  }
105
105
  }
106
106
  })
107
- } else {
107
+ } else if (this.css) {
108
108
  let from = this.opts.from
109
109
  ? this.toUrl(this.path(this.opts.from))
110
110
  : '<no source>'
@@ -191,7 +191,9 @@ class MapGenerator {
191
191
  } else {
192
192
  this.map = new SourceMapGenerator({ file: this.outputFile() })
193
193
  this.map.addMapping({
194
- source: this.opts.from ? this.toUrl(this.opts.from) : '<no source>',
194
+ source: this.opts.from
195
+ ? this.toUrl(this.path(this.opts.from))
196
+ : '<no source>',
195
197
  generated: { line: 1, column: 0 },
196
198
  original: { line: 1, column: 0 }
197
199
  })
@@ -8,6 +8,7 @@ const Result = require('./result')
8
8
 
9
9
  class NoWorkResult {
10
10
  constructor(processor, css, opts) {
11
+ css = css.toString()
11
12
  this.stringified = false
12
13
 
13
14
  this._processor = processor
@@ -77,9 +78,12 @@ class NoWorkResult {
77
78
  this.error = error
78
79
  }
79
80
 
80
- this._root = root
81
-
82
- return root
81
+ if (this.error) {
82
+ throw this.error
83
+ } else {
84
+ this._root = root
85
+ return root
86
+ }
83
87
  }
84
88
 
85
89
  get messages() {
package/lib/parser.js CHANGED
@@ -139,10 +139,12 @@ class Parser {
139
139
  if (brackets.length > 0) this.unclosedBracket(bracket)
140
140
 
141
141
  if (end && colon) {
142
- while (tokens.length) {
143
- token = tokens[tokens.length - 1][0]
144
- if (token !== 'space' && token !== 'comment') break
145
- this.tokenizer.back(tokens.pop())
142
+ if (!customProperty) {
143
+ while (tokens.length) {
144
+ token = tokens[tokens.length - 1][0]
145
+ if (token !== 'space' && token !== 'comment') break
146
+ this.tokenizer.back(tokens.pop())
147
+ }
146
148
  }
147
149
  this.decl(tokens, customProperty)
148
150
  } else {
@@ -208,7 +210,15 @@ class Parser {
208
210
  node.raws.before += node.prop[0]
209
211
  node.prop = node.prop.slice(1)
210
212
  }
211
- let firstSpaces = this.spacesAndCommentsFromStart(tokens)
213
+
214
+ let firstSpaces = []
215
+ let next
216
+ while (tokens.length) {
217
+ next = tokens[0][0]
218
+ if (next !== 'space' && next !== 'comment') break
219
+ firstSpaces.push(tokens.shift())
220
+ }
221
+
212
222
  this.precheckMissedSemicolon(tokens)
213
223
 
214
224
  for (let i = tokens.length - 1; i >= 0; i--) {
@@ -242,12 +252,12 @@ class Parser {
242
252
  }
243
253
 
244
254
  let hasWord = tokens.some(i => i[0] !== 'space' && i[0] !== 'comment')
245
- this.raw(node, 'value', tokens)
255
+
246
256
  if (hasWord) {
247
- node.raws.between += firstSpaces
248
- } else {
249
- node.value = firstSpaces + node.value
257
+ node.raws.between += firstSpaces.map(i => i[1]).join('')
258
+ firstSpaces = []
250
259
  }
260
+ this.raw(node, 'value', firstSpaces.concat(tokens), customProperty)
251
261
 
252
262
  if (node.value.includes(':') && !customProperty) {
253
263
  this.checkMissedSemicolon(tokens)
@@ -395,38 +405,26 @@ class Parser {
395
405
  if (node.type !== 'comment') this.semicolon = false
396
406
  }
397
407
 
398
- raw(node, prop, tokens) {
408
+ raw(node, prop, tokens, customProperty) {
399
409
  let token, type
400
410
  let length = tokens.length
401
411
  let value = ''
402
412
  let clean = true
403
413
  let next, prev
404
- let pattern = /^([#.|])?(\w)+/i
405
414
 
406
415
  for (let i = 0; i < length; i += 1) {
407
416
  token = tokens[i]
408
417
  type = token[0]
409
-
410
- if (type === 'comment' && node.type === 'rule') {
418
+ if (type === 'space' && i === length - 1 && !customProperty) {
419
+ clean = false
420
+ } else if (type === 'comment') {
411
421
  prev = tokens[i - 1]
412
422
  next = tokens[i + 1]
413
-
414
- if (
415
- prev[0] !== 'space' &&
416
- next[0] !== 'space' &&
417
- pattern.test(prev[1]) &&
418
- pattern.test(next[1])
419
- ) {
423
+ if (prev && next && prev[0] !== 'space' && next[0] !== 'space') {
420
424
  value += token[1]
421
425
  } else {
422
426
  clean = false
423
427
  }
424
-
425
- continue
426
- }
427
-
428
- if (type === 'comment' || (type === 'space' && i === length - 1)) {
429
- clean = false
430
428
  } else {
431
429
  value += token[1]
432
430
  }
package/lib/processor.js CHANGED
@@ -7,7 +7,7 @@ let Root = require('./root')
7
7
 
8
8
  class Processor {
9
9
  constructor(plugins = []) {
10
- this.version = '8.4.2'
10
+ this.version = '8.4.6'
11
11
  this.plugins = this.normalize(plugins)
12
12
  }
13
13
 
package/lib/rule.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import Container, { ContainerProps } from './container.js'
2
2
 
3
- interface RuleRaws {
3
+ interface RuleRaws extends Record<string, unknown> {
4
4
  /**
5
5
  * The space symbols before the node. It also stores `*`
6
6
  * and `_` symbols before the declaration (IE hack).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.4.2",
3
+ "version": "8.4.6",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
5
  "engines": {
6
6
  "node": "^10 || ^12 || >=14"
@@ -65,9 +65,9 @@
65
65
  "url": "https://github.com/postcss/postcss/issues"
66
66
  },
67
67
  "dependencies": {
68
- "nanoid": "^3.1.30",
68
+ "nanoid": "^3.2.0",
69
69
  "picocolors": "^1.0.0",
70
- "source-map-js": "^1.0.1"
70
+ "source-map-js": "^1.0.2"
71
71
  },
72
72
  "browser": {
73
73
  "./lib/terminal-highlight": false,