postcss 8.0.5 → 8.0.9
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/CHANGELOG.md +14 -0
- package/lib/at-rule.js +2 -2
- package/lib/container.js +42 -21
- package/lib/node.js +4 -0
- package/lib/postcss.d.ts +1 -1
- package/lib/postcss.js +7 -0
- package/lib/processor.d.ts +1 -0
- package/lib/processor.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
# Change Log
|
2
2
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
3
3
|
|
4
|
+
## 8.0.9
|
5
|
+
* Replace prototype in PostCSS 7 nodes instead of recreating them.
|
6
|
+
* Added missed `Transformer` to exported types (by Pierre-Marie Dartus).
|
7
|
+
|
8
|
+
## 8.0.8
|
9
|
+
* Fix `8.0.7` regression on PostCSS 7 nodes converting (by Adam Wathan).
|
10
|
+
|
11
|
+
## 8.0.7
|
12
|
+
* Fixed compatibility issue with mixin AST with PostCSS 7 and 8 nodes.
|
13
|
+
* Added migration guide translation to Chinese to the warning.
|
14
|
+
|
15
|
+
## 8.0.6
|
16
|
+
* Fixed child adding methods in `Container`.
|
17
|
+
|
4
18
|
## 8.0.5
|
5
19
|
* Update changelog.
|
6
20
|
|
package/lib/at-rule.js
CHANGED
@@ -9,12 +9,12 @@ class AtRule extends Container {
|
|
9
9
|
}
|
10
10
|
|
11
11
|
append (...children) {
|
12
|
-
if (!this.nodes) this.nodes = []
|
12
|
+
if (!this.proxyOf.nodes) this.nodes = []
|
13
13
|
return super.append(...children)
|
14
14
|
}
|
15
15
|
|
16
16
|
prepend (...children) {
|
17
|
-
if (!this.nodes) this.nodes = []
|
17
|
+
if (!this.proxyOf.nodes) this.nodes = []
|
18
18
|
return super.prepend(...children)
|
19
19
|
}
|
20
20
|
}
|
package/lib/container.js
CHANGED
@@ -18,28 +18,47 @@ function cleanSource (nodes) {
|
|
18
18
|
function markDirtyUp (node) {
|
19
19
|
node[isClean] = false
|
20
20
|
node[isComplete] = false
|
21
|
-
if (node.nodes) {
|
22
|
-
for (let i of node.nodes) {
|
21
|
+
if (node.proxyOf.nodes) {
|
22
|
+
for (let i of node.proxyOf.nodes) {
|
23
23
|
markDirtyUp(i)
|
24
24
|
}
|
25
25
|
}
|
26
26
|
}
|
27
27
|
|
28
|
+
// istanbul ignore next
|
29
|
+
function rebuild (node) {
|
30
|
+
if (node.type === 'atrule') {
|
31
|
+
Object.setPrototypeOf(node, AtRule.prototype)
|
32
|
+
} else if (node.type === 'rule') {
|
33
|
+
Object.setPrototypeOf(node, Rule.prototype)
|
34
|
+
} else if (node.type === 'decl') {
|
35
|
+
Object.setPrototypeOf(node, Declaration.prototype)
|
36
|
+
} else if (node.type === 'comment') {
|
37
|
+
Object.setPrototypeOf(node, Comment.prototype)
|
38
|
+
}
|
39
|
+
|
40
|
+
if (node.nodes) {
|
41
|
+
node.nodes.forEach(child => {
|
42
|
+
rebuild(child)
|
43
|
+
})
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
28
47
|
class Container extends Node {
|
29
48
|
push (child) {
|
30
49
|
child.parent = this
|
31
|
-
this.nodes.push(child)
|
50
|
+
this.proxyOf.nodes.push(child)
|
32
51
|
return this
|
33
52
|
}
|
34
53
|
|
35
54
|
each (callback) {
|
36
|
-
if (!this.nodes) return undefined
|
55
|
+
if (!this.proxyOf.nodes) return undefined
|
37
56
|
let iterator = this.getIterator()
|
38
57
|
|
39
58
|
let index, result
|
40
|
-
while (this.indexes[iterator] < this.nodes.length) {
|
59
|
+
while (this.indexes[iterator] < this.proxyOf.nodes.length) {
|
41
60
|
index = this.indexes[iterator]
|
42
|
-
result = callback(this.nodes[index], index)
|
61
|
+
result = callback(this.proxyOf.nodes[index], index)
|
43
62
|
if (result === false) break
|
44
63
|
|
45
64
|
this.indexes[iterator] += 1
|
@@ -146,7 +165,7 @@ class Container extends Node {
|
|
146
165
|
append (...children) {
|
147
166
|
for (let child of children) {
|
148
167
|
let nodes = this.normalize(child, this.last)
|
149
|
-
for (let node of nodes) this.nodes.push(node)
|
168
|
+
for (let node of nodes) this.proxyOf.nodes.push(node)
|
150
169
|
}
|
151
170
|
|
152
171
|
this.markDirty()
|
@@ -158,7 +177,7 @@ class Container extends Node {
|
|
158
177
|
children = children.reverse()
|
159
178
|
for (let child of children) {
|
160
179
|
let nodes = this.normalize(child, this.first, 'prepend').reverse()
|
161
|
-
for (let node of nodes) this.nodes.unshift(node)
|
180
|
+
for (let node of nodes) this.proxyOf.nodes.unshift(node)
|
162
181
|
for (let id in this.indexes) {
|
163
182
|
this.indexes[id] = this.indexes[id] + nodes.length
|
164
183
|
}
|
@@ -180,8 +199,8 @@ class Container extends Node {
|
|
180
199
|
exist = this.index(exist)
|
181
200
|
|
182
201
|
let type = exist === 0 ? 'prepend' : false
|
183
|
-
let nodes = this.normalize(add, this.nodes[exist], type).reverse()
|
184
|
-
for (let node of nodes) this.nodes.splice(exist, 0, node)
|
202
|
+
let nodes = this.normalize(add, this.proxyOf.nodes[exist], type).reverse()
|
203
|
+
for (let node of nodes) this.proxyOf.nodes.splice(exist, 0, node)
|
185
204
|
|
186
205
|
let index
|
187
206
|
for (let id in this.indexes) {
|
@@ -199,8 +218,8 @@ class Container extends Node {
|
|
199
218
|
insertAfter (exist, add) {
|
200
219
|
exist = this.index(exist)
|
201
220
|
|
202
|
-
let nodes = this.normalize(add, this.nodes[exist]).reverse()
|
203
|
-
for (let node of nodes) this.nodes.splice(exist + 1, 0, node)
|
221
|
+
let nodes = this.normalize(add, this.proxyOf.nodes[exist]).reverse()
|
222
|
+
for (let node of nodes) this.proxyOf.nodes.splice(exist + 1, 0, node)
|
204
223
|
|
205
224
|
let index
|
206
225
|
for (let id in this.indexes) {
|
@@ -217,8 +236,8 @@ class Container extends Node {
|
|
217
236
|
|
218
237
|
removeChild (child) {
|
219
238
|
child = this.index(child)
|
220
|
-
this.nodes[child].parent = undefined
|
221
|
-
this.nodes.splice(child, 1)
|
239
|
+
this.proxyOf.nodes[child].parent = undefined
|
240
|
+
this.proxyOf.nodes.splice(child, 1)
|
222
241
|
|
223
242
|
let index
|
224
243
|
for (let id in this.indexes) {
|
@@ -234,8 +253,8 @@ class Container extends Node {
|
|
234
253
|
}
|
235
254
|
|
236
255
|
removeAll () {
|
237
|
-
for (let node of this.nodes) node.parent = undefined
|
238
|
-
this.nodes = []
|
256
|
+
for (let node of this.proxyOf.nodes) node.parent = undefined
|
257
|
+
this.proxyOf.nodes = []
|
239
258
|
|
240
259
|
this.markDirty()
|
241
260
|
|
@@ -271,17 +290,17 @@ class Container extends Node {
|
|
271
290
|
index (child) {
|
272
291
|
if (typeof child === 'number') return child
|
273
292
|
if (child.proxyOf) child = child.proxyOf
|
274
|
-
return this.nodes.indexOf(child)
|
293
|
+
return this.proxyOf.nodes.indexOf(child)
|
275
294
|
}
|
276
295
|
|
277
296
|
get first () {
|
278
|
-
if (!this.nodes) return undefined
|
279
|
-
return this.nodes[0]
|
297
|
+
if (!this.proxyOf.nodes) return undefined
|
298
|
+
return this.proxyOf.nodes[0]
|
280
299
|
}
|
281
300
|
|
282
301
|
get last () {
|
283
|
-
if (!this.nodes) return undefined
|
284
|
-
return this.nodes[this.nodes.length - 1]
|
302
|
+
if (!this.proxyOf.nodes) return undefined
|
303
|
+
return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
|
285
304
|
}
|
286
305
|
|
287
306
|
normalize (nodes, sample) {
|
@@ -317,6 +336,8 @@ class Container extends Node {
|
|
317
336
|
}
|
318
337
|
|
319
338
|
let processed = nodes.map(i => {
|
339
|
+
// istanbul ignore next
|
340
|
+
if (typeof i.markDirty !== 'function') rebuild(i)
|
320
341
|
if (i.parent) i.parent.removeChild(i)
|
321
342
|
if (i[isClean]) markDirtyUp(i)
|
322
343
|
if (typeof i.raws.before === 'undefined') {
|
package/lib/node.js
CHANGED
package/lib/postcss.d.ts
CHANGED
package/lib/postcss.js
CHANGED
@@ -30,6 +30,13 @@ postcss.plugin = function plugin (name, initializer) {
|
|
30
30
|
'postcss.plugin was deprecated. Migration guide:\n' +
|
31
31
|
'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
|
32
32
|
)
|
33
|
+
if (process.env.LANG && process.env.LANG.startsWith('cn')) {
|
34
|
+
// istanbul ignore next
|
35
|
+
console.warn(
|
36
|
+
'postcss.plugin 被弃用. 迁移指南:\n' +
|
37
|
+
'https://www.w3ctech.com/topic/2226'
|
38
|
+
)
|
39
|
+
}
|
33
40
|
}
|
34
41
|
function creator (...args) {
|
35
42
|
let transformer = initializer(...args)
|
package/lib/processor.d.ts
CHANGED
package/lib/processor.js
CHANGED