core icon indicating copy to clipboard operation
core copied to clipboard

feat(vapor): forwarded slots

Open edison1105 opened this issue 6 months ago โ€ข 5 comments

Playground with this PR

foo is a forwarded slot, it is executed, the currentInstance in createSlot is the instance of Comp, but it should be the instance of Comp1.

  const n2 = _createComponent(Comp, null, {
    "foo": () => { 
      const n0 = _createSlot("foo", null) 
      return n0
    }
  }, true)

Therefore, we need to preserve the current component's instance for forwarded slots and use it in createSlot, similar to how withCtx works in VDOM slots. With this PR, the compiled code changes to:

  const _createForwardedSlot = _forwardedSlotCreator()
  const n2 = _createComponent(Comp, null, {
    "foo": () => {
      const n0 = _createForwardedSlot("foo", null)
      return n0
    }
  }, true)

Inside the forwardedSlotCreator, the currentInstance is retained and a function is returned, which calls createSlot and passes the retained instance.

edison1105 avatar May 29 '25 09:05 edison1105

Deploy Preview for vapor-repl ready!

Name Link
Latest commit 748686a3f94df3fda596b636ec5104d7c09598f3
Latest deploy log https://app.netlify.com/projects/vapor-repl/deploys/6854fe2e9bdf2400084357f4
Deploy Preview https://deploy-preview-13408--vapor-repl.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar May 29 '25 09:05 netlify[bot]

[!IMPORTANT]

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

โœจ Finishing touches
๐Ÿงช Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch edison/feat/fowardedSlots

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar May 29 '25 09:05 coderabbitai[bot]

Open in StackBlitz

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@13408
@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@13408
@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@13408
@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@13408
@vue/compiler-vapor

npm i https://pkg.pr.new/@vue/compiler-vapor@13408
@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@13408
@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@13408
@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@13408
@vue/runtime-vapor

npm i https://pkg.pr.new/@vue/runtime-vapor@13408
@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@13408
@vue/shared

npm i https://pkg.pr.new/@vue/shared@13408
vue

npm i https://pkg.pr.new/vue@13408
@vue/compat

npm i https://pkg.pr.new/@vue/compat@13408

commit: eb8f270

pkg-pr-new[bot] avatar May 29 '25 09:05 pkg-pr-new[bot]

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 84.5 kB 30 kB 26.4 kB
runtime-dom.global.prod.js 105 kB (+93 B) 39.4 kB (+50 B) 35.5 kB (+19 B)
vue.global.prod.js 163 kB (+93 B) 59.6 kB (+48 B) 53.1 kB (+44 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 47.4 kB 18.5 kB 16.9 kB
createApp 56.2 kB 21.7 kB 19.8 kB
createApp + vaporInteropPlugin 79.9 kB (+837 B) 29.8 kB (+283 B) 27.1 kB (+302 B)
createVaporApp 31.3 kB (+431 B) 12 kB (+135 B) 11 kB (+129 B)
createSSRApp 60.5 kB 23.4 kB 21.4 kB
defineCustomElement 61.2 kB 23.2 kB 21.2 kB
overall 71.1 kB 27 kB 24.6 kB

github-actions[bot] avatar Jul 16 '25 12:07 github-actions[bot]