Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit 92c284d

Browse files
committed
Fixup toAttributePosition with array name
1 parent 85e5b32 commit 92c284d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/parser/stage-2-ast.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,12 @@ function buildAst(
976976
return builder;
977977
}
978978

979+
function nameLength(names: (ConcreteLiquidDrop | ConcreteTextNode)[]) {
980+
const start = names.at(0)!;
981+
const end = names.at(-1)!;
982+
return end.locEnd - start.locStart;
983+
}
984+
979985
function toAttributePosition(
980986
node:
981987
| ConcreteAttrSingleQuoted
@@ -987,12 +993,12 @@ function toAttributePosition(
987993
// This is bugged when there's whitespace on either side. But I don't
988994
// think it's worth solving.
989995
return {
990-
start: node.locStart + node.name.length + '='.length + '"'.length,
996+
start: node.locStart + nameLength(node.name) + '='.length + '"'.length,
991997
// name=""
992998
// 012345678
993999
// 0 + 4 + 1 + 1
9941000
// = 6
995-
end: node.locStart + node.name.length + '='.length + '"'.length,
1001+
end: node.locStart + nameLength(node.name) + '='.length + '"'.length,
9961002
// name=""
9971003
// 012345678
9981004
// 0 + 4 + 1 + 2

0 commit comments

Comments
 (0)