Skip to content

Conversation

@johnsoncodehk
Copy link
Member

Fix #5899

The issue was introduced by the post-processing of normalizeTemplateAST in #5782.

When normalizeTemplateAST calls createIfBranch, it retrieves the offset to calculate the position of the conditional expression. Since @vue/language-plugin proxies the offset property, createIfBranch obtains the offset based on the Pug position.

Subsequently, the node with the Pug position is added to the AST tree. The proxy from @vue/language-plugin establishes a proxy for the new node, causing the next retrieval of offset to map the already Pug-positioned offset from HTML to Pug again, resulting in an incorrect outcome.

The issue occurs in normalizeIfBranch, so it only happens when a Pug template uses both v-slot and v-if on the same node.

The solution is to avoid using a proxy and perform the HTML to Pug conversion in advance within compileSFCTemplate.

@johnsoncodehk johnsoncodehk changed the title fix(language-plugin-pug): pre-complete HTML to Pug mapping fix(language-plugin-pug): pre-map HTML to Pug offset Dec 24, 2025
@johnsoncodehk johnsoncodehk changed the title fix(language-plugin-pug): pre-map HTML to Pug offset fix(language-plugin-pug): pre-map HTML to Pug offset attribute Dec 24, 2025
@johnsoncodehk johnsoncodehk merged commit 8fdfe99 into master Dec 24, 2025
7 checks passed
@johnsoncodehk johnsoncodehk deleted the pug-mapping branch December 24, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Getting error TS1005 after upgrading from v3.1.5

2 participants