-
-
Notifications
You must be signed in to change notification settings - Fork 724
feat(parse/html): support vue directive syntax #7673
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
base: next
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 92c92e7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
Co-authored-by: Naoki Ikeguchi <me@s6n.jp>
VueDirective | ||
| VueVBindShorthandDirective | ||
| VueVOnShorthandDirective |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually a Any*
node should have a bogus node as part of the variants
|
||
// <div @click="onClick" /> | ||
// ^^^^^^^^^^^^^^^^ | ||
VueVOnShorthandDirective = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where there's a VOn
in the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@click
is shorthand for v-on:click
&& byte != b':' | ||
&& byte != b'.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's to stop consume_identifier
from progressing when it encounters those, and get the lexer to emit them as their own tokens.
It would probably make more sense to have another lex context InsideTagVue
to gate this behavior behind.
let m = p.start(); | ||
|
||
p.bump_with_context(T![.], HtmlLexContext::InsideTag); | ||
p.bump_with_context(HTML_LITERAL, HtmlLexContext::InsideTag); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p.bump_with_context(HTML_LITERAL, HtmlLexContext::InsideTag); | |
p.expect_with_context(HTML_LITERAL, HtmlLexContext::InsideTag); |
Can't recall if we have this function, but we can't bump without checking first
parse_vue_directive_argument(p).ok(); | ||
VueModifierList.parse_list(p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If parse_vue_directive_argument
emits an error, it's almost possible that line 37 will fail too. Shouldn't we bail and emit a bogus node? Or are there test that shows that the parsing of modifiers can succeed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably bail, yeah
BTW I fixed the failing test in another branch, so we can ignore it |
Summary
This PR adds support for parsing vue directives in
.vue
files.It's still a WIP, the parser should be finished, but the lexer needs to be a little smarter in order to emit the right tokens.
Test Plan
Added tests.
Docs