Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): comment can cause vIf-related syntax errors #6843

wants to merge 2 commits into from


Copy link

@Dunqing Dunqing commented Oct 10, 2022

fix: keep comments in production and have a comment between v-if and v-else, encounter [vite:vue] v-else/v-else-if has no adjacent v-if or v-else-if. error

Why is test work?

Since the following code works in the test, the comments can be skipped.

if (__DEV__ && sibling && sibling.type === NodeTypes.COMMENT) {

Steps to reproduce

  1. open the reproduction
  2. executed npm run build
  3. Error appears

Copy link

antfu commented Oct 12, 2022

Can you add some tests to it? Thanks

Copy link
Contributor Author

Dunqing commented Oct 12, 2022

This test is the same as this issue, so I don't need to add the same cases for the test.

test('with comments', () => {
const { node } = parseWithIfTransform(`
<template v-if="ok">
<div v-if="ok2">
<b v-else/>

antfu approved these changes Oct 12, 2022
@LinusBorg LinusBorg added the ready to merge The PR is ready to be merged. label Oct 21, 2022
@yyx990803 yyx990803 closed this in dd3354c Nov 8, 2022
Copy link

Thanks for the PR. We still need a separate test case for this to better document the problem, and we should not introduce test-only logic to fix a case. See dd3354c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ready to merge The PR is ready to be merged.
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants