-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Incorrect compiled code when usinig multiline v-if on template element as a slot renderer #9114
Comments
as a workaround, one can put parenthesis themselves. I think we could add wrapping parenthesis if the expression starts with a newline |
In my case, I simply can't put the parenthesis, they are stripped out automatically by Prettier. But the issue is still valid and I think the same, the expression should be wrapped. |
I think i am missing something here. Will both return statements not evaluate to the same thing? I checked the operator precedence and checked the syntax tree generated(assuming http://esprima.org/demo/parse.html is reliable). Would like to work on this once i understand what i am missing. |
A return alone on a line will insert a semicolon at the end of the line,
thus returning undefined
On Wed 28 Nov 2018 at 04:53, Subhash ***@***.***> wrote:
I think i am missing something here. Will both return statements not
evaluate to the same thing? I checked the operator precedence and checked
the syntax tree generated(assuming http://esprima.org/demo/parse.html is
reliable).
Would like to work on this once i understand what i am missing.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#9114 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAoicRIQmUgJ-8YkScigzyU4zy57yjxJks5uzgidgaJpZM4Y1rl9>
.
--
Eduardo San Martin Morote
|
I got it. I will look at the code and get back with my thoughts.
|
Version
2.5.17
Reproduction link
https://template-explorer.vuejs.org/#%3Cdiv%3E%0A%20%20%20%20%3Ctemplate%0A%20%20%20%20%20%20slot%3D%22row_expander%22%0A%20%20%20%20%20%20slot-scope%3D%22%7B%0A%20%20%20%20%20%20%20%20row%0A%20%20%20%20%20%20%7D%22%0A%20%20%20%20%20%20v-if%3D%22%0A%20%20%20%20%20%20%20%20longCondition1%20%26%26%0A%20%20%20%20%20%20%20%20anotherLongCondition%20%3D%3D%3D%20'my%20awesome%20result'%20%26%26%0A%20%20%20%20%20%20%20%20anotherWhichBreakTheLineLength%0A%20%20%20%20%20%20%22%0A%20%20%20%20%3E%0A%20%20%20%20%20%20%3Csomething%20%2F%3E%20%3Csomething%20%2F%3E%0A%20%20%20%20%3C%2Ftemplate%3E%0A%20%3C%2Fdiv%3E
Steps to reproduce
When using a
v-if
which match these 3 conditions:template
elementslot
property…then the template compiler does not encapsulate the code in parenthesis, leading to improper condition.
See the provided Vue Template Explorer for the following code:
What is expected?
The return of scopedSlots.fn must encapsulate the condition inside parenthesis.
What is actually happening?
The return statement is incorrect.
This is related to the usage of Prettier which automatically break on multiple lines the condition if it is too long (see prettier/prettier#5561)
The text was updated successfully, but these errors were encountered: