[Vue][Bug] Long v-if condition break the code after reformat
See original GitHub issuePrettier 1.15.2 Vue 2.5.17 Playground link
# Options (if any):
--parser vue
Input:
A v-if
is used on a template
element which is also declared as a slot
.
<template>
<div>
<template
slot="row_expander"
slot-scope="{row}"
v-if="longCondition1 && anotherLongCondition === 'my awesome result' && anotherWhichBreakTheLineLength">
<something />
<something/>
</template>
</div>
</template>
Output:
<template>
<div>
<template
slot="row_expander"
slot-scope="{
row
}"
v-if="
longCondition1 &&
anotherLongCondition === 'my awesome result' &&
anotherWhichBreakTheLineLength
"
>
<something /> <something />
</template>
</div>
</template>
In this particular case (usage on template element which is a slot renderer), the resulting code will break.
Expected behavior: The code must be encapsulated in parenthesis to properly work. (And indentation may be better imho.)
<template>
<div>
<template
slot="row_expander"
slot-scope="{
row
}"
v-if="(
longCondition1 &&
anotherLongCondition === 'my awesome result' &&
anotherWhichBreakTheLineLength
) "
>
<something /> <something />
</template>
</div>
</template>
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How To Use Break, Continue, and Pass Statements when ...
You'll put the break statement within the block of code under your loop statement, usually after a conditional if statement.
Read more >break - JavaScript - MDN Web Docs - Mozilla
The following code has a break statement that terminates the switch statement when a case is matched and the corresponding code has run....
Read more >Why does python use 'else' after for and while loops?
Without break , return , etc., loop ends only when condition is no longer true and in such case else block will also...
Read more >Python break statement - Tutorialspoint
If you are using nested loops, the break statement stops the execution of the innermost loop and start executing the next line of...
Read more >Python Break and Python Continue – How to Skip to the Next ...
Inside the for loop, we have a condition that says if the letter is "i" then skip that iteration and move onto the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As a workaround, you could use
<!-- prettier-ignore-attribute v-if -->
:Prettier 1.15.2 Playground link
Input:
Output:
Fixed in vuejs/vue#9119.