core icon indicating copy to clipboard operation
core copied to clipboard

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

Open Dunqing opened this issue 3 years ago • 2 comments

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. https://github.com/vuejs/core/blob/35dc2bbe7d22a4b551f912612f8d4f04788005a7/packages/compiler-core/src/transforms/vIf.ts#L132-L136

Steps to reproduce

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

Dunqing avatar Oct 10 '22 10:10 Dunqing

Can you add some tests to it? Thanks

antfu avatar Oct 12 '22 07:10 antfu

This test is the same as this issue, so I don't need to add the same cases for the test. https://github.com/vuejs/core/blob/35dc2bbe7d22a4b551f912612f8d4f04788005a7/packages/compiler-core/tests/transforms/vIf.spec.ts#L652-L664

Dunqing avatar Oct 12 '22 08:10 Dunqing

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 dd3354c4

yyx990803 avatar Nov 08 '22 15:11 yyx990803