fix(runtime-vapor): take in account parent component scopeid on nested slot#14326
fix(runtime-vapor): take in account parent component scopeid on nested slot#14326edison1105 merged 4 commits intovuejs:minorfrom
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 You can disable this status message by setting the 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/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
| @@ -160,6 +160,8 @@ export function getScopeOwner(): VaporComponentInstance | null { | |||
| */ | |||
| export function withVaporCtx(fn: Function): BlockFn { | |||
| const owner = currentInstance as VaporComponentInstance | |||
There was a problem hiding this comment.
The correct fix should be
const owner = getScopeOwner()There was a problem hiding this comment.
Wow, that's interesting, it works! I thought currentSlotOwner would be null there. Thanks for hint, will fix
There was a problem hiding this comment.
In App.vue, the currentSlotOwner is always the instance of App. I have already changed the code.
Thank you for your contribution.
Setting scoped style class (defined in parent component) in nested slot is ignored in vapor mode, example:
vapor repl
This worked before, on vdom:
vdom repl
Also works with this PR:
PR repl
I dig into runtime code, looks like scopeId is taken from slot owner, which is set within
withVaporCtx.However, when there are more than one nested components, rendered code produces more than one
withVaporCtx. So, child component takesscopeIdfrom lastwithVaporCtxcall.I'm not sure how to fix it in right way, so I mark PR as a draft, feel free to close if it not good solution.
What I propose in this PR is to mark instances used in
withVaporCtxand then look for latest parent in hierarchy marked as slot owner.Current unit tests are passing, looks like I did not break anything. I also added basic test which check whether correct scope Id is set.
Results:

Without PR (see first link):
With PR:
