postcss 8.4.4 → 8.4.7

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).
@@ -78,9 +78,12 @@ class NoWorkResult {
78
78
  this.error = error
79
79
  }
80
80
 
81
- this._root = root
82
-
83
- return root
81
+ if (this.error) {
82
+ throw this.error
83
+ } else {
84
+ this._root = root
85
+ return root
86
+ }
84
87
  }
85
88
 
86
89
  get messages() {
package/lib/node.d.ts CHANGED
@@ -3,7 +3,7 @@ import Comment, { CommentProps } from './comment.js'
3
3
  import { Stringifier, Syntax } from './postcss.js'
4
4
  import AtRule, { AtRuleProps } from './at-rule.js'
5
5
  import Rule, { RuleProps } from './rule.js'
6
- import { WarningOptions } from './warning.js'
6
+ import Warning, { WarningOptions } from './warning.js'
7
7
  import CssSyntaxError from './css-syntax-error.js'
8
8
  import Result from './result.js'
9
9
  import Input from './input.js'
@@ -241,7 +241,7 @@ export default abstract class Node {
241
241
  *
242
242
  * @return Created warning object.
243
243
  */
244
- warn(result: Result, text: string, opts?: WarningOptions): void
244
+ warn(result: Result, text: string, opts?: WarningOptions): Warning
245
245
 
246
246
  /**
247
247
  * Removes the node from its parent and cleans the parent properties
package/lib/parser.js CHANGED
@@ -7,6 +7,11 @@ let AtRule = require('./at-rule')
7
7
  let Root = require('./root')
8
8
  let Rule = require('./rule')
9
9
 
10
+ const SAFE_COMMENT_NEIGHBOR = {
11
+ empty: true,
12
+ space: true
13
+ }
14
+
10
15
  class Parser {
11
16
  constructor(input) {
12
17
  this.input = input
@@ -139,10 +144,12 @@ class Parser {
139
144
  if (brackets.length > 0) this.unclosedBracket(bracket)
140
145
 
141
146
  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())
147
+ if (!customProperty) {
148
+ while (tokens.length) {
149
+ token = tokens[tokens.length - 1][0]
150
+ if (token !== 'space' && token !== 'comment') break
151
+ this.tokenizer.back(tokens.pop())
152
+ }
146
153
  }
147
154
  this.decl(tokens, customProperty)
148
155
  } else {
@@ -208,7 +215,15 @@ class Parser {
208
215
  node.raws.before += node.prop[0]
209
216
  node.prop = node.prop.slice(1)
210
217
  }
211
- let firstSpaces = this.spacesAndCommentsFromStart(tokens)
218
+
219
+ let firstSpaces = []
220
+ let next
221
+ while (tokens.length) {
222
+ next = tokens[0][0]
223
+ if (next !== 'space' && next !== 'comment') break
224
+ firstSpaces.push(tokens.shift())
225
+ }
226
+
212
227
  this.precheckMissedSemicolon(tokens)
213
228
 
214
229
  for (let i = tokens.length - 1; i >= 0; i--) {
@@ -242,12 +257,12 @@ class Parser {
242
257
  }
243
258
 
244
259
  let hasWord = tokens.some(i => i[0] !== 'space' && i[0] !== 'comment')
245
- this.raw(node, 'value', tokens)
260
+
246
261
  if (hasWord) {
247
- node.raws.between += firstSpaces
248
- } else {
249
- node.value = firstSpaces + node.value
262
+ node.raws.between += firstSpaces.map(i => i[1]).join('')
263
+ firstSpaces = []
250
264
  }
265
+ this.raw(node, 'value', firstSpaces.concat(tokens), customProperty)
251
266
 
252
267
  if (node.value.includes(':') && !customProperty) {
253
268
  this.checkMissedSemicolon(tokens)
@@ -395,38 +410,30 @@ class Parser {
395
410
  if (node.type !== 'comment') this.semicolon = false
396
411
  }
397
412
 
398
- raw(node, prop, tokens) {
413
+ raw(node, prop, tokens, customProperty) {
399
414
  let token, type
400
415
  let length = tokens.length
401
416
  let value = ''
402
417
  let clean = true
403
418
  let next, prev
404
- let pattern = /^([#.|])?(\w)+/i
405
419
 
406
420
  for (let i = 0; i < length; i += 1) {
407
421
  token = tokens[i]
408
422
  type = token[0]
409
-
410
- if (type === 'comment' && node.type === 'rule') {
411
- prev = tokens[i - 1]
412
- 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
- ) {
420
- value += token[1]
423
+ if (type === 'space' && i === length - 1 && !customProperty) {
424
+ clean = false
425
+ } else if (type === 'comment') {
426
+ prev = tokens[i - 1] ? tokens[i - 1][0] : 'empty'
427
+ next = tokens[i + 1] ? tokens[i + 1][0] : 'empty'
428
+ if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
429
+ if (value.slice(-1) === ',') {
430
+ clean = false
431
+ } else {
432
+ value += token[1]
433
+ }
421
434
  } else {
422
435
  clean = false
423
436
  }
424
-
425
- continue
426
- }
427
-
428
- if (type === 'comment' || (type === 'space' && i === length - 1)) {
429
- clean = false
430
437
  } else {
431
438
  value += token[1]
432
439
  }
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.4'
10
+ this.version = '8.4.7'
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.4",
3
+ "version": "8.4.7",
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.3.1",
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,