postcss 8.5.30 → 8.5.32

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/input.js CHANGED
@@ -230,7 +230,7 @@ class Input {
230
230
  } else {
231
231
  fromUrl = new URL(
232
232
  from.source,
233
- this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile)
233
+ pathToFileURL(this.map.mapFile || resolve('.') + '/')
234
234
  )
235
235
  }
236
236
 
@@ -205,7 +205,7 @@ class LazyResult {
205
205
  }
206
206
 
207
207
  finally(onFinally) {
208
- return this.async().then(onFinally, onFinally)
208
+ return this.async().finally(onFinally)
209
209
  }
210
210
 
211
211
  getAsyncError() {
@@ -102,7 +102,7 @@ class NoWorkResult {
102
102
  }
103
103
 
104
104
  finally(onFinally) {
105
- return this.async().then(onFinally, onFinally)
105
+ return this.async().finally(onFinally)
106
106
  }
107
107
 
108
108
  sync() {
package/lib/node.js CHANGED
@@ -240,7 +240,7 @@ class Node {
240
240
  } else if (opts.word) {
241
241
  let stringRepresentation = inputString.slice(
242
242
  sourceOffset(inputString, this.source.start),
243
- sourceOffset(inputString, this.source.end)
243
+ this.rangeBy().end.offset
244
244
  )
245
245
  let index = stringRepresentation.indexOf(opts.word)
246
246
  if (index !== -1) pos = this.positionInside(index)
@@ -308,7 +308,7 @@ class Node {
308
308
  if (opts.word) {
309
309
  let stringRepresentation = inputString.slice(
310
310
  sourceOffset(inputString, this.source.start),
311
- sourceOffset(inputString, this.source.end)
311
+ end.offset
312
312
  )
313
313
  let index = stringRepresentation.indexOf(opts.word)
314
314
  if (index !== -1) {
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.5.30'
10
+ this.version = '8.5.32'
11
11
  this.plugins = this.normalize(plugins)
12
12
  }
13
13
 
package/lib/stringify.js CHANGED
@@ -10,8 +10,30 @@ function escapeHTMLInCSS(str) {
10
10
  return str.replace(STYLE_TAG, '\\3c $2').replace(COMMENT_OPEN, '\\3c $2')
11
11
  }
12
12
 
13
+ function cutEscaped(chunks, css, escaped) {
14
+ let parts = []
15
+ let at = 0
16
+ let into = 0
17
+ for (let i = 0; i < chunks.length; i += 3) {
18
+ let from = into
19
+ let end = at + chunks[i].length
20
+ while (at < end) {
21
+ if (css[at] === escaped[into]) {
22
+ at += 1
23
+ into += 1
24
+ } else {
25
+ // The `<` of this pair was replaced by the `\3c ` in front of it
26
+ at += 1
27
+ into += 4
28
+ }
29
+ }
30
+ parts.push(escaped.slice(from, into))
31
+ }
32
+ return parts
33
+ }
34
+
13
35
  class SafeStringifier extends Stringifier {
14
- escapeHTML(node, print) {
36
+ escapeHTML(print) {
15
37
  let builder = this.builder
16
38
  let chunks, css
17
39
  this.builder = (str, child, type) => {
@@ -39,20 +61,20 @@ class SafeStringifier extends Stringifier {
39
61
  builder(chunks[i], chunks[i + 1], chunks[i + 2])
40
62
  }
41
63
  } else {
42
- // Escaping happens only on a hack attempt, source map is not important.
43
- // Map only the node start: the end mapping expects the node’s last
44
- // char at the end of the string, which is wrong for Root raws.after.
45
- builder(escaped, node, 'start')
64
+ let parts = cutEscaped(chunks, css, escaped)
65
+ for (let i = 0; i < chunks.length; i += 3) {
66
+ builder(parts[i / 3], chunks[i + 1], chunks[i + 2])
67
+ }
46
68
  }
47
69
  }
48
70
 
49
71
  root(node) {
50
72
  if (node.parent && node.parent.type === 'document') {
51
73
  // Document raws around the Root hold markup and are kept as is since CSS in Document can be marked with <style>
52
- this.escapeHTML(node, () => this.body(node))
74
+ this.escapeHTML(() => this.body(node))
53
75
  if (node.raws.after) this.builder(node.raws.after)
54
76
  } else {
55
- this.escapeHTML(node, () => super.root(node))
77
+ this.escapeHTML(() => super.root(node))
56
78
  }
57
79
  }
58
80
  }
@@ -63,7 +85,7 @@ function stringify(node, builder) {
63
85
  if (node.type === 'root' || node.type === 'document') {
64
86
  str.stringify(node)
65
87
  } else {
66
- str.escapeHTML(node, () => str.stringify(node))
88
+ str.escapeHTML(() => str.stringify(node))
67
89
  }
68
90
  }
69
91
 
package/lib/warning.js CHANGED
@@ -31,6 +31,7 @@ class Warning {
31
31
  return this.node.error(this.text, {
32
32
  index: this.index,
33
33
  plugin: this.plugin,
34
+ start: this.start,
34
35
  word: this.word
35
36
  }).message
36
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.5.30",
3
+ "version": "8.5.32",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
5
  "keywords": [
6
6
  "css",