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

class and style merging conflict with vue.template.compilerOptions.whitespace preserve #9285

Open
yanghoxom opened this issue Sep 25, 2023 · 5 comments
Labels
✨ feature request New feature or request

Comments

@yanghoxom
Copy link

Vue version

3.3.4

Link to minimal reproduction

https://stackblitz.com/edit/github-gjgfy8

Steps to reproduce

Vite 4.4.9
set option compilerOptions.whitespace = "preserve"

What is expected?

option compilerOptions.whitespace and style and merging work correctly

What is actually happening?

if we leave a comment before the first element in the template
style and class merging do not work

System Info

No response

Any additional comments?

No response

@edison1105
Copy link
Member

edison1105 commented Sep 25, 2023

I did not get your point or see anything related to whitespace.
Do you mean the class-from-parent does not fall through to the HasComment.vue component?
image
if so, this is the expected behavior. here is a warning:
image

@yanghoxom
Copy link
Author

yanghoxom commented Sep 25, 2023

@edison1105

if so, this is the expected behavior. here is a warning:

if I remove config whitespace: 'preserve',
it will be able to inherit normally even if the first element in template is a comment
this is why I think is the conflict between them

@edison1105
Copy link
Member

edison1105 commented Sep 25, 2023

the root cause is:
\n will render as an empty text node if preserving whitespace, that lead attrs does not fall through. I feel this is expected behavior for now, because if replace the comment with a text node, the attrs also do not fall through. see.
but this is room to improve this. eg: ignore text nodes when falling through attrs.

@memsenpai
there seems no workaround except adding a root tag or removing whitespace: 'preserve'.

@edison1105 edison1105 added the ✨ feature request New feature or request label Sep 25, 2023
@yanghoxom
Copy link
Author

@edison1105
thank you for reply

it still works fine in vue 2, where \n will be converted to whitespace, and despite the comment at the top, style and class extend still works fine.

Are you sure this is expected behavior and not a bug?

@edison1105
Copy link
Member

@memsenpai
Actually, I am not sure if it is a bug. let's wait for others' input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants