feat(compiler-core): support false prop shorthand#14110
feat(compiler-core): support false prop shorthand#14110KazariEX wants to merge 2 commits intovuejs:mainfrom
Conversation
📝 WalkthroughWalkthroughThese changes introduce support for the "false shorthand" syntax in v-bind directives, enabling Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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.
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.
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/compiler-core/src/parser.ts (1)
201-233: Provide a reallocfor implicitfalseexpressions to avoid invalid offsets.
createSimpleExpression('false')useslocStub. If this directive is later converted to an attribute (e.g., due tov-pre),dirToAttradjustslocand can produce negative offsets, corrupting source locations. Consider providing a concrete location.🔧 Suggested fix
- exp: raw === '!' ? createSimpleExpression('false') : undefined, + exp: raw === '!' ? createSimpleExpression('false', false, getLoc(start, end)) : undefined,
resolve vuejs/rfcs#777
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.