postcss 8.5.0 → 8.5.1
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/node.js +17 -8
- package/lib/processor.js +1 -1
- package/package.json +1 -1
package/lib/node.js
CHANGED
@@ -209,9 +209,12 @@ class Node {
|
|
209
209
|
if (opts.index) {
|
210
210
|
pos = this.positionInside(opts.index)
|
211
211
|
} else if (opts.word) {
|
212
|
-
let
|
213
|
-
|
214
|
-
|
212
|
+
let inputString = ('document' in this.source.input)
|
213
|
+
? this.source.input.document
|
214
|
+
: this.source.input.css
|
215
|
+
let stringRepresentation = inputString.slice(
|
216
|
+
sourceOffset(inputString, this.source.start),
|
217
|
+
sourceOffset(inputString, this.source.end)
|
215
218
|
)
|
216
219
|
let index = stringRepresentation.indexOf(opts.word)
|
217
220
|
if (index !== -1) pos = this.positionInside(index)
|
@@ -222,11 +225,14 @@ class Node {
|
|
222
225
|
positionInside(index) {
|
223
226
|
let column = this.source.start.column
|
224
227
|
let line = this.source.start.line
|
225
|
-
let
|
228
|
+
let inputString = ('document' in this.source.input)
|
229
|
+
? this.source.input.document
|
230
|
+
: this.source.input.css
|
231
|
+
let offset = sourceOffset(inputString, this.source.start)
|
226
232
|
let end = offset + index
|
227
233
|
|
228
234
|
for (let i = offset; i < end; i++) {
|
229
|
-
if (
|
235
|
+
if (inputString[i] === '\n') {
|
230
236
|
column = 1
|
231
237
|
line += 1
|
232
238
|
} else {
|
@@ -259,9 +265,12 @@ class Node {
|
|
259
265
|
}
|
260
266
|
|
261
267
|
if (opts.word) {
|
262
|
-
let
|
263
|
-
|
264
|
-
|
268
|
+
let inputString = ('document' in this.source.input)
|
269
|
+
? this.source.input.document
|
270
|
+
: this.source.input.css
|
271
|
+
let stringRepresentation = inputString.slice(
|
272
|
+
sourceOffset(inputString, this.source.start),
|
273
|
+
sourceOffset(inputString, this.source.end)
|
265
274
|
)
|
266
275
|
let index = stringRepresentation.indexOf(opts.word)
|
267
276
|
if (index !== -1) {
|
package/lib/processor.js
CHANGED