feat: in-tag comments#831
Conversation
|
这是来自QQ邮箱的自动回复邮件。
我已经收到了你的来信,我会尽快回复。
|
|
My first reaction was that this is a great feature — really nice to be able to comment inside the opening tag. Just out of curiosity, not a strong opinion either way — the Template Syntax docs (https://vuejs.org/guide/essentials/template-syntax.html) currently promise:
A |
|
I don't have a strong preference regarding the comment style, but although JS-style comments like those in sveltejs/svelte#17671 can be parsed by spec-compliant HTML parsers when they don't contain certain special characters, they still change the semantics of the generated AST. I think that's hard to avoid, so we might as well add it as a complete feature from the start. |
|
I think Vue's syntax should largely stay within the bounds of HTML. In Html, This is Invalid. It's true that Svelte recently added support for this, but I don't think that, by itself, is a reason for Vue to do the same. We can try via consoleconst d = new DOMParser().parseFromString(`
<div <!-- commnet -->>hello</div>
`, "text/html")
d.body.children[0].attributes |
|
This RFC was not intended to introduce syntax incompatible with HTML; it's merely a side effect of the current implementation. I sincerely hope the team can explore a more compatible solution. |
I think a better way to frame this is as "an SFC-only syntax add-on", similar to the case-sensitive tag names. And since this is a syntax add-on, I'd prefer the Svelte-like |
|
if the main issue is to ignore the attribute, why not proposing to extend I also would prefer the |
|
I think the motivation is valid, especially for supporting line-level tooling directives such as Vue already has the compile-time If in-tag comments use the same So if this feature is essentially a Vue/SFC-specific compile-time annotation, I’d lean toward a non-HTML-comment-looking syntax such as |
|
Updated to use the JS style syntax. |
|
Also, if we decide to support this, I think we’ll need to work closely with @johnsoncodehk and make sure we stay aligned with Language Tools support (especially tmLanguage support). |
|
My way is to add <MyComponent
_="my comment"
_some-prop="disabled now"
/>It's HTML-compatible |
Summary
@vue-expect-error