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 +1 -1
- package/lib/lazy-result.js +1 -1
- package/lib/no-work-result.js +1 -1
- package/lib/node.js +2 -2
- package/lib/processor.js +1 -1
- package/lib/stringify.js +30 -8
- package/lib/warning.js +1 -0
- package/package.json +1 -1
package/lib/input.js
CHANGED
package/lib/lazy-result.js
CHANGED
package/lib/no-work-result.js
CHANGED
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
|
-
|
|
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
|
-
|
|
311
|
+
end.offset
|
|
312
312
|
)
|
|
313
313
|
let index = stringRepresentation.indexOf(opts.word)
|
|
314
314
|
if (index !== -1) {
|
package/lib/processor.js
CHANGED
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(
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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(
|
|
74
|
+
this.escapeHTML(() => this.body(node))
|
|
53
75
|
if (node.raws.after) this.builder(node.raws.after)
|
|
54
76
|
} else {
|
|
55
|
-
this.escapeHTML(
|
|
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(
|
|
88
|
+
str.escapeHTML(() => str.stringify(node))
|
|
67
89
|
}
|
|
68
90
|
}
|
|
69
91
|
|
package/lib/warning.js
CHANGED