postcss 8.5.10 → 8.5.11

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.
@@ -378,6 +378,16 @@ class LazyResult {
378
378
  if (opts.stringifier) str = opts.stringifier
379
379
  if (str.stringify) str = str.stringify
380
380
 
381
+ let rootSource = this.result.root.source
382
+ if (opts.map === undefined && !(rootSource && rootSource.input && rootSource.input.map)) {
383
+ let result = ''
384
+ str(this.result.root, i => {
385
+ result += i
386
+ })
387
+ this.result.css = result
388
+ return this.result
389
+ }
390
+
381
391
  let map = new MapGenerator(str, this.result.root, this.result.opts)
382
392
  let data = map.generate()
383
393
  this.result.css = data[0]
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.10'
10
+ this.version = '8.5.11'
11
11
  this.plugins = this.normalize(plugins)
12
12
  }
13
13
 
@@ -37,11 +37,12 @@ class Stringifier {
37
37
  }
38
38
 
39
39
  atrule(node, semicolon) {
40
+ let raws = node.raws
40
41
  let name = '@' + node.name
41
42
  let params = node.params ? this.rawValue(node, 'params') : ''
42
43
 
43
- if (typeof node.raws.afterName !== 'undefined') {
44
- name += node.raws.afterName
44
+ if (typeof raws.afterName !== 'undefined') {
45
+ name += raws.afterName
45
46
  } else if (params) {
46
47
  name += ' '
47
48
  }
@@ -49,7 +50,7 @@ class Stringifier {
49
50
  if (node.nodes) {
50
51
  this.block(node, name + params)
51
52
  } else {
52
- let end = (node.raws.between || '') + (semicolon ? ';' : '')
53
+ let end = (raws.between || '') + (semicolon ? ';' : '')
53
54
  this.builder(escapeHTMLInCSS(name + params + end), node)
54
55
  }
55
56
  }
@@ -84,15 +85,22 @@ class Stringifier {
84
85
  }
85
86
 
86
87
  block(node, start) {
87
- let between = this.raw(node, 'between', 'beforeOpen')
88
+ let raws = node.raws
89
+ let between = typeof raws.between !== 'undefined'
90
+ ? raws.between
91
+ : this.raw(node, 'between', 'beforeOpen')
88
92
  this.builder(escapeHTMLInCSS(start + between) + '{', node, 'start')
89
93
 
90
94
  let after
91
95
  if (node.nodes && node.nodes.length) {
92
96
  this.body(node)
93
- after = this.raw(node, 'after')
97
+ after = typeof raws.after !== 'undefined'
98
+ ? raws.after
99
+ : this.raw(node, 'after')
94
100
  } else {
95
- after = this.raw(node, 'after', 'emptyBody')
101
+ after = typeof raws.after !== 'undefined'
102
+ ? raws.after
103
+ : this.raw(node, 'after', 'emptyBody')
96
104
  }
97
105
 
98
106
  if (after) this.builder(escapeHTMLInCSS(after))
@@ -100,34 +108,50 @@ class Stringifier {
100
108
  }
101
109
 
102
110
  body(node) {
103
- let last = node.nodes.length - 1
111
+ let nodes = node.nodes
112
+ let last = nodes.length - 1
104
113
  while (last > 0) {
105
- if (node.nodes[last].type !== 'comment') break
114
+ if (nodes[last].type !== 'comment') break
106
115
  last -= 1
107
116
  }
108
117
 
109
118
  let semicolon = this.raw(node, 'semicolon')
110
119
  let isDocument = node.type === 'document'
111
- for (let i = 0; i < node.nodes.length; i++) {
112
- let child = node.nodes[i]
113
- let before = this.raw(child, 'before')
120
+ for (let i = 0; i < nodes.length; i++) {
121
+ let child = nodes[i]
122
+ let before = child.raws.before
123
+ if (typeof before === 'undefined') {
124
+ before = this.raw(child, 'before')
125
+ }
114
126
  if (before) this.builder(isDocument ? before : escapeHTMLInCSS(before))
115
127
  this.stringify(child, last !== i || semicolon)
116
128
  }
117
129
  }
118
130
 
119
131
  comment(node) {
120
- let left = this.raw(node, 'left', 'commentLeft')
121
- let right = this.raw(node, 'right', 'commentRight')
132
+ let raws = node.raws
133
+ let left = typeof raws.left !== 'undefined'
134
+ ? raws.left
135
+ : this.raw(node, 'left', 'commentLeft')
136
+ let right = typeof raws.right !== 'undefined'
137
+ ? raws.right
138
+ : this.raw(node, 'right', 'commentRight')
122
139
  this.builder(escapeHTMLInCSS('/*' + left + node.text + right + '*/'), node)
123
140
  }
124
141
 
125
142
  decl(node, semicolon) {
126
- let between = this.raw(node, 'between', 'colon')
127
- let string = node.prop + between + this.rawValue(node, 'value')
143
+ let raws = node.raws
144
+ let between = typeof raws.between !== 'undefined'
145
+ ? raws.between
146
+ : this.raw(node, 'between', 'colon')
147
+
148
+ let rawVal = raws.value
149
+ let value = rawVal && rawVal.value === node.value ? rawVal.raw : node.value
150
+
151
+ let string = node.prop + between + value
128
152
 
129
153
  if (node.important) {
130
- string += node.raws.important || ' !important'
154
+ string += raws.important || ' !important'
131
155
  }
132
156
 
133
157
  if (semicolon) string += ';'
@@ -167,9 +191,9 @@ class Stringifier {
167
191
 
168
192
  // Detect style by other nodes
169
193
  let root = node.root()
170
- if (!root.rawCache) root.rawCache = {}
171
- if (typeof root.rawCache[detect] !== 'undefined') {
172
- return root.rawCache[detect]
194
+ let cache = root.rawCache || (root.rawCache = {})
195
+ if (typeof cache[detect] !== 'undefined') {
196
+ return cache[detect]
173
197
  }
174
198
 
175
199
  if (detect === 'before' || detect === 'after') {
@@ -188,7 +212,7 @@ class Stringifier {
188
212
 
189
213
  if (typeof value === 'undefined') value = DEFAULT_RAW[detect]
190
214
 
191
- root.rawCache[detect] = value
215
+ cache[detect] = value
192
216
  return value
193
217
  }
194
218
 
package/lib/tokenize.js CHANGED
@@ -36,6 +36,7 @@ module.exports = function tokenizer(input, options = {}) {
36
36
  let pos = 0
37
37
  let buffer = []
38
38
  let returned = []
39
+ let lastBadParen = -1
39
40
 
40
41
  function position() {
41
42
  return pos
@@ -127,11 +128,14 @@ module.exports = function tokenizer(input, options = {}) {
127
128
  currentToken = ['brackets', css.slice(pos, next + 1), pos, next]
128
129
 
129
130
  pos = next
131
+ } else if (pos <= lastBadParen) {
132
+ currentToken = ['(', '(', pos]
130
133
  } else {
131
134
  next = css.indexOf(')', pos + 1)
132
135
  content = css.slice(pos, next + 1)
133
136
 
134
137
  if (next === -1 || RE_BAD_BRACKET.test(content)) {
138
+ lastBadParen = next === -1 ? length : next
135
139
  currentToken = ['(', '(', pos]
136
140
  } else {
137
141
  currentToken = ['brackets', content, pos, next]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.5.10",
3
+ "version": "8.5.11",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
5
  "keywords": [
6
6
  "css",