Skip to content

Commit 80deeba

Browse files
committed
fix: ensure attr tag nodes added to correct ast location
1 parent b6db132 commit 80deeba

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

.changeset/warm-chicken-remain.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"marko-widgets": patch
3+
"@marko/compat-v4": patch
4+
---
5+
6+
Ensure legacy attribute tags are added to correct ast location.

packages/compat-v4/src/migrate/legacy-attribute-tags.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,21 @@ export default {
5151
);
5252
}
5353

54-
tag.replaceWith(
55-
t.markoTag(
56-
attrTagNameLiteral,
57-
node.attributes,
58-
node.body,
59-
node.arguments,
60-
node.var,
61-
node.attributeTags,
62-
),
54+
const replacement = t.markoTag(
55+
attrTagNameLiteral,
56+
node.attributes,
57+
node.body,
58+
node.arguments,
59+
node.var,
60+
node.attributeTags,
6361
);
62+
63+
if (tag.node.attributeTags) {
64+
tag.remove();
65+
parentTag.pushContainer("attributeTags", replacement);
66+
} else {
67+
tag.replaceWith(replacement);
68+
}
6469
},
6570
});
6671
}

0 commit comments

Comments
 (0)