- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.9k
 
fix(runtime-core): pass props and children to loadingComponent #13997
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
          
WalkthroughThe loading-state path now wraps the resolved loading component with  Changes
 Sequence Diagram(s)sequenceDiagram
  autonumber
  participant App as App
  participant AsyncWrapper as AsyncWrapper
  participant Resolver as Resolver
  participant InnerComp as createInnerComp
  participant Loading as LoadingComponent
  App->>AsyncWrapper: render async component
  AsyncWrapper->>Resolver: resolve loadingComponent (pending)
  Resolver-->>AsyncWrapper: loadingComponent (resolved)
  note right of AsyncWrapper #E6F7FF: New: wrap resolved\nwith createInnerComp
  AsyncWrapper->>InnerComp: createInnerComp(loadingComponent, instance)
  InnerComp->>Loading: instantiate as inner component
  Loading-->>App: render (inherits wrapper context)
    sequenceDiagram
  autonumber
  participant AsyncWrapper as AsyncWrapper
  participant Resolver as Resolver
  participant VNode as createVNode
  participant Loading as LoadingComponent
  AsyncWrapper->>Resolver: resolve loadingComponent (pending)
  Resolver-->>AsyncWrapper: loadingComponent (resolved)
  note right of AsyncWrapper #FFF4E6: Old: direct vnode creation
  AsyncWrapper->>VNode: createVNode(loadingComponent)
  VNode->>Loading: instantiate as standalone vnode (no wrapper context)
    Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 
 Suggested labels
 Poem
 Pre-merge checks and finishing touches✅ Passed checks (3 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
 🚧 Files skipped from review as they are similar to previous changes (1)
 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:   | 
    
| 
           Thanks for the PR. It would be better if you added a test case.  | 
    
Co-authored-by: edison <daiwei521@126.com>
This PR offers some backwards compatibility with Vue 2
In some cases you will want to use passed properties and children to the loading component, this was possible in Vue 2 but not in Vue 3. This PR gets you that ability back.
For some background, i have a heavy autocomplete bar requiring some big libraries which i do not want to load unless the autocomplete gets used.
For this i've created an async component that gets loaded after an event gets fired. This event would get fired when focussing on the "facade" input:
This worked perfectly in Vue 2, however with Vue 3 this results in
this.$slots.default is not a functionwhich makes sense because the loadingComponent does not actually get access to their props and children.Summary by CodeRabbit