Repository navigation
fix(compiler-vapor): let v-for and v-slot scope variables shadow known globals - #16006
meta-syntax wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
Size ReportBundles
Usages
|
|
Thanks for the PR. #15813 addressed a concrete use case, including a setup component named I don’t think we need to add more handling for these cases solely for completeness. Renaming the local binding is a straightforward workaround. Closing this for now; we can revisit it if a concrete user report shows a practical need. |
Follow-up to #15813, which lets setup bindings shadow known globals.
In Vapor, a
v-foralias / key or av-slotprop named like a known global (Date,Number, ...) is treated as the global:In VDOM,
Datein this template refers to thev-foralias.This PR adds a
scopeargument toisConstantExpressionandisConstantBinding, so that a known global is not treated as a constant when av-for/v-slotscope variable has the same name.The transform implements
scopewithisScopeVariablefrom #15810, and codegen implements it with itsidentifiers.isScopeVariableonly checks whether av-for/v-slotof the parent elements declares the name, which is not specific tov-model.So this PR moves it from
vModel.tstoutils.ts, together withhasScopeBinding(fromtransformElement.ts) that it calls, without changing them.The compiler output changes only when a scope variable has the name of a known global. At compile time, the parent elements are searched only when the expression is a known global name.
The added tests check only the compiler output and fail without the fix.