feat(compiler): correct source map generation

This commit is contained in:
Evan You
2019-09-26 14:55:53 -04:00
parent 2e3a1ff3c3
commit 63b6902bdb
8 changed files with 120 additions and 111 deletions

View File

@@ -542,6 +542,7 @@ function parseAttribute(
valueLoc.start.offset++
valueLoc.start.column++
valueLoc.end = advancePositionWithClone(valueLoc.start, value.content)
valueLoc.source = valueLoc.source.slice(1, -1)
}
return {
@@ -642,15 +643,26 @@ function parseInterpolation(
return undefined
}
const start = getCursor(context)
advanceBy(context, open.length)
const content = parseTextData(context, closeIndex - open.length, mode).trim()
const start = getCursor(context)
const end = getCursor(context)
const rawContentLength = closeIndex - open.length
const rawContent = context.source.slice(0, rawContentLength)
const preTrimContent = parseTextData(context, rawContentLength, mode)
const content = preTrimContent.trim()
const startOffset = preTrimContent.indexOf(content)
if (startOffset > 0) {
advancePositionWithMutation(start, rawContent, startOffset)
}
const endOffset =
rawContentLength - (preTrimContent.length - content.length - startOffset)
advancePositionWithMutation(end, rawContent, endOffset)
advanceBy(context, close.length)
return {
type: NodeTypes.EXPRESSION,
content,
loc: getSelection(context, start),
loc: getSelection(context, start, end),
isStatic: content === '',
isInterpolation: true
}