-
-
Notifications
You must be signed in to change notification settings - Fork 9k
feat(compiler-core): support false prop shorthand #14110
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: main
Are you sure you want to change the base?
Conversation
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/compiler-core/src/parser.ts (1)
200-233:!→bindmapping and defaultfalseexp look correct; consider the<div !>edge caseMapping
raw === '!'to thebinddirective and seedingexpwith afalseSimpleExpression gives<div !id />the same internal shape asv-bind:id="false", and stays consistent with how.,:,@, and#are treated here. Using a synthetic expression (no real source span) also makes sense sincefalseis implicit in the shorthand.One behavioral edge case to be aware of:
<div ! />will now parse as abinddirective with no arg andexp = false(effectivelyv-bind="false"), rather than producing a missing-arg error. If RFC 777 expects that to be invalid, you might want to special‑caseraw === '!'with an empty arg to emit an error instead; otherwise this behavior is consistent with the rest of the parser.packages/compiler-core/__tests__/transforms/vBind.spec.ts (1)
136-149: New false‑shorthand test is aligned with the intended semanticsThis test cleanly validates that
<div !id />compiles to a propid: falsewith a static key and non‑static value, matching the new parser behavior. For future hardening (not blocking here), you might also add variants withprefixIdentifiers: trueand/or dynamic args (e.g.![foo]) to lock in those combinations.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/compiler-core/__tests__/transforms/vBind.spec.ts(1 hunks)packages/compiler-core/src/parser.ts(2 hunks)packages/compiler-core/src/tokenizer.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/compiler-core/__tests__/transforms/vBind.spec.ts (1)
packages/compiler-core/src/ast.ts (2)
VNodeCall(323-341)ObjectExpression(374-377)
packages/compiler-core/src/parser.ts (1)
packages/compiler-core/src/ast.ts (1)
createSimpleExpression(685-698)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test / e2e-test
🔇 Additional comments (1)
packages/compiler-core/src/tokenizer.ts (1)
664-681: Extending directive prefix detection to!is consistent and localizedRouting
!through the directive path here (same bucket as.,:,@,#) correctly feedsondirnamea raw'!'and then parses the rest as the arg. This aligns tokenizer behavior with the parser’s new handling and keeps all existing attr/dir state transitions intact. The only functional change is that attrs starting with!are no longer plain attributes but directives, which seems acceptable given HTML’s constraints and the RFC intent.
resolve vuejs/rfcs#777
Summary by CodeRabbit
!notation to concisely set binding values to false, improving code readability for boolean attribute bindings (e.g.,<div !id />).