full site update
This commit is contained in:
69
node_modules/postcss/lib/node.js
generated
vendored
69
node_modules/postcss/lib/node.js
generated
vendored
@@ -34,11 +34,8 @@ function cloneNode(obj, parent) {
|
||||
|
||||
function sourceOffset(inputCSS, position) {
|
||||
// Not all custom syntaxes support `offset` in `source.start` and `source.end`
|
||||
if (
|
||||
position &&
|
||||
typeof position.offset !== 'undefined'
|
||||
) {
|
||||
return position.offset;
|
||||
if (position && typeof position.offset !== 'undefined') {
|
||||
return position.offset
|
||||
}
|
||||
|
||||
let column = 1
|
||||
@@ -208,14 +205,15 @@ class Node {
|
||||
return this.parent.nodes[index + 1]
|
||||
}
|
||||
|
||||
positionBy(opts) {
|
||||
positionBy(opts = {}) {
|
||||
let pos = this.source.start
|
||||
if (opts.index) {
|
||||
pos = this.positionInside(opts.index)
|
||||
} else if (opts.word) {
|
||||
let inputString = ('document' in this.source.input)
|
||||
? this.source.input.document
|
||||
: this.source.input.css
|
||||
let inputString =
|
||||
'document' in this.source.input
|
||||
? this.source.input.document
|
||||
: this.source.input.css
|
||||
let stringRepresentation = inputString.slice(
|
||||
sourceOffset(inputString, this.source.start),
|
||||
sourceOffset(inputString, this.source.end)
|
||||
@@ -229,9 +227,10 @@ class Node {
|
||||
positionInside(index) {
|
||||
let column = this.source.start.column
|
||||
let line = this.source.start.line
|
||||
let inputString = ('document' in this.source.input)
|
||||
? this.source.input.document
|
||||
: this.source.input.css
|
||||
let inputString =
|
||||
'document' in this.source.input
|
||||
? this.source.input.document
|
||||
: this.source.input.css
|
||||
let offset = sourceOffset(inputString, this.source.start)
|
||||
let end = offset + index
|
||||
|
||||
@@ -244,7 +243,7 @@ class Node {
|
||||
}
|
||||
}
|
||||
|
||||
return { column, line }
|
||||
return { column, line, offset: end }
|
||||
}
|
||||
|
||||
prev() {
|
||||
@@ -253,25 +252,36 @@ class Node {
|
||||
return this.parent.nodes[index - 1]
|
||||
}
|
||||
|
||||
rangeBy(opts) {
|
||||
rangeBy(opts = {}) {
|
||||
let inputString =
|
||||
'document' in this.source.input
|
||||
? this.source.input.document
|
||||
: this.source.input.css
|
||||
let start = {
|
||||
column: this.source.start.column,
|
||||
line: this.source.start.line
|
||||
line: this.source.start.line,
|
||||
offset: sourceOffset(inputString, this.source.start)
|
||||
}
|
||||
let end = this.source.end
|
||||
? {
|
||||
column: this.source.end.column + 1,
|
||||
line: this.source.end.line
|
||||
line: this.source.end.line,
|
||||
offset:
|
||||
typeof this.source.end.offset === 'number'
|
||||
? // `source.end.offset` is exclusive, so we don't need to add 1
|
||||
this.source.end.offset
|
||||
: // Since line/column in this.source.end is inclusive,
|
||||
// the `sourceOffset(... , this.source.end)` returns an inclusive offset.
|
||||
// So, we add 1 to convert it to exclusive.
|
||||
sourceOffset(inputString, this.source.end) + 1
|
||||
}
|
||||
: {
|
||||
column: start.column + 1,
|
||||
line: start.line
|
||||
line: start.line,
|
||||
offset: start.offset + 1
|
||||
}
|
||||
|
||||
if (opts.word) {
|
||||
let inputString = ('document' in this.source.input)
|
||||
? this.source.input.document
|
||||
: this.source.input.css
|
||||
let stringRepresentation = inputString.slice(
|
||||
sourceOffset(inputString, this.source.start),
|
||||
sourceOffset(inputString, this.source.end)
|
||||
@@ -279,15 +289,14 @@ class Node {
|
||||
let index = stringRepresentation.indexOf(opts.word)
|
||||
if (index !== -1) {
|
||||
start = this.positionInside(index)
|
||||
end = this.positionInside(
|
||||
index + opts.word.length,
|
||||
)
|
||||
end = this.positionInside(index + opts.word.length)
|
||||
}
|
||||
} else {
|
||||
if (opts.start) {
|
||||
start = {
|
||||
column: opts.start.column,
|
||||
line: opts.start.line
|
||||
line: opts.start.line,
|
||||
offset: sourceOffset(inputString, opts.start)
|
||||
}
|
||||
} else if (opts.index) {
|
||||
start = this.positionInside(opts.index)
|
||||
@@ -296,7 +305,8 @@ class Node {
|
||||
if (opts.end) {
|
||||
end = {
|
||||
column: opts.end.column,
|
||||
line: opts.end.line
|
||||
line: opts.end.line,
|
||||
offset: sourceOffset(inputString, opts.end)
|
||||
}
|
||||
} else if (typeof opts.endIndex === 'number') {
|
||||
end = this.positionInside(opts.endIndex)
|
||||
@@ -309,7 +319,11 @@ class Node {
|
||||
end.line < start.line ||
|
||||
(end.line === start.line && end.column <= start.column)
|
||||
) {
|
||||
end = { column: start.column + 1, line: start.line }
|
||||
end = {
|
||||
column: start.column + 1,
|
||||
line: start.line,
|
||||
offset: start.offset + 1
|
||||
}
|
||||
}
|
||||
|
||||
return { end, start }
|
||||
@@ -384,6 +398,7 @@ class Node {
|
||||
} else if (typeof value === 'object' && value.toJSON) {
|
||||
fixed[name] = value.toJSON(null, inputs)
|
||||
} else if (name === 'source') {
|
||||
if (value == null) continue
|
||||
let inputId = inputs.get(value.input)
|
||||
if (inputId == null) {
|
||||
inputId = inputsNextIndex
|
||||
@@ -423,7 +438,7 @@ class Node {
|
||||
return result
|
||||
}
|
||||
|
||||
warn(result, text, opts) {
|
||||
warn(result, text, opts = {}) {
|
||||
let data = { node: this }
|
||||
for (let i in opts) data[i] = opts[i]
|
||||
return result.warn(text, data)
|
||||
|
Reference in New Issue
Block a user