postcss 8.5.30 → 8.5.31

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/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.31'
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.5.30",
3
+ "version": "8.5.31",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
5
  "keywords": [
6
6
  "css",