fix: attr method shorthand source map position (#1806)

This commit is contained in:
Dylan Piercey 2022-06-04 21:15:16 -07:00 committed by GitHub
parent 059bd35d8b
commit 04adc2d24e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
"@marko/compiler": patch
---
Fix issue where attribute shorthand methods would have incorrect sourcemap position.

View File

@ -326,12 +326,18 @@ export function parseMarko(file) {
},
onAttrMethod(part) {
const prefix = "function";
currentAttr.end = part.end;
currentAttr.value = parseExpression(
file,
prefix + parser.read(part),
part.start - prefix.length
currentAttr.value = withLoc(
t.functionExpression(
undefined,
parseExpression(
file,
`${parser.read(part.params)}=>{}`,
part.params.start
).params,
parseScript(file, parser.read(part.body), part.body.start).body[0]
),
part
);
},