Skip to content

Commit

Permalink
fix: child tag name analysis (#2372)
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey authored Nov 21, 2024
1 parent b511096 commit 2fa5df5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-boxes-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/translator-tags": patch
---

Ensure tag name type analysis only returns a custom tag when we can perform child template analysis.
18 changes: 10 additions & 8 deletions packages/translator-tags/src/util/tag-name-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ export default function analyzeTagNameType(tag: t.NodePath<t.MarkoTag>) {
referencedBindings: bindingIdentifier.extra?.binding,
};
analyzeExpressionTagName(name.replaceWith(tagIdentifier)[0], extra);
} else {
const childFile = loadFileForTag(tag);
if (!childFile) {
extra.tagNameType = TagNameType.DynamicTag;
} else if (childFile.ast.program.extra!.featureType === "class") {
extra.tagNameType = TagNameType.DynamicTag;
extra.featureType = "class";
}
}
}

Expand All @@ -78,6 +70,16 @@ export default function analyzeTagNameType(tag: t.NodePath<t.MarkoTag>) {
if (extra.tagNameType === undefined) {
extra.tagNameType = TagNameType.DynamicTag;
}

if (extra.tagNameType === TagNameType.CustomTag) {
const childFile = loadFileForTag(tag);
if (!childFile) {
extra.tagNameType = TagNameType.DynamicTag;
} else if (childFile.ast.program.extra!.featureType === "class") {
extra.tagNameType = TagNameType.DynamicTag;
extra.featureType = "class";
}
}
}

return extra.tagNameType;
Expand Down

0 comments on commit 2fa5df5

Please sign in to comment.