Skip to content

Commit d6e7a1d

Browse files
committed
fix: attribute tags pre analyze transforms
1 parent c1d752c commit d6e7a1d

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.changeset/lemon-coats-grow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@marko/runtime-tags": patch
3+
---
4+
5+
Fix attribute tags not being included in pre analyze transforms.

packages/runtime-tags/src/translator/visitors/program/pre-analyze.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@ export function preAnalyze(program: t.NodePath<t.Program>) {
2525

2626
function normalizeBody(
2727
state: State,
28-
body: t.NodePath<
29-
t.Program["body"][number] | t.MarkoTagBody["body"][number]
30-
>[],
28+
body:
29+
| undefined
30+
| t.NodePath<
31+
| t.Program["body"][number]
32+
| t.MarkoTagBody["body"][number]
33+
| t.MarkoTag["attributeTags"]
34+
>[],
3135
) {
32-
for (const child of body) {
33-
if (child.isMarkoTag()) {
34-
normalizeTag(state, child);
36+
if (body?.length) {
37+
for (const child of body) {
38+
if (child.isMarkoTag()) {
39+
normalizeTag(state, child);
40+
}
3541
}
3642
}
3743
}
@@ -40,6 +46,7 @@ function normalizeTag(state: State, tag: t.NodePath<t.MarkoTag>) {
4046
const { node } = tag;
4147
const { name, attributes } = node;
4248
normalizeBody(state, tag.get("body").get("body"));
49+
normalizeBody(state, tag.get("attributeTags"));
4350

4451
if (node.var) {
4552
const insertions = getAssignmentInsertions(node.var);

0 commit comments

Comments
 (0)