Skip to content
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

feat(vapor): vapor transition + transition-group #12962

Draft
wants to merge 46 commits into
base: vapor
Choose a base branch
from

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Feb 27, 2025

Compiler Changes

  • Within Vapor components, Transition is automatically rewritten as VaporTransition during compilation
  • When the root node of a Transition uses the v-if, the compiler automatically adds a $key property to the rendering result, making it easier for the runtime to track the element's leaving state using the key
  <Transition>
    <h1 v-if="show">
      <span>HI</span>
    </h1>
  </Transition>

will be compiled to

  const n4 = _createComponent(_VaporTransition, null, {
    "default": () => {
      const n1 = _createIf(() => (_ctx.show), () => {
        const n3 = t1()
        n3.$key = 3 // adds a `$key` 
        return n3
      })
      return n1
    }
  })
  • When the root node of a Transition has an explicit key, the compiler generates code that includes createKeyedFragment, which creates a new DynamicFragment when the key changes, triggering transitions
  <Transition>
    <span :key="count">{{ count }}</span>
  </Transition>

will be compiled to

  const n1 = _createComponent(_VaporTransition, null, {
    "default": () => {
      return _createKeyedFragment(() => _ctx.count, () => {
        const n0 = t0()
        const x0 = _child(n0)
        _renderEffect(() => _setText(x0, _toDisplayString(_ctx.count)))
        n0.$key = _ctx.count
        return n0
      })
    }
  })

Runtime Changes

  • Added VaporTransition component that reuses most of the logic from runtime-dom/Transition
  • Transition hooks are now stored on the block.$transition property
  • DynamicFragment Update Logic Modification:
    • When removing old elements, leave animations are triggered
    • When rendering new elements, enter animations are triggered
  • Extracted baseResolveTransitionHooks from the existing resolveTransitionHooks function to be shared between VaporTransition and Transition. Each component passes its own specific TransitionHooksContext
  • Interop:
    • Existing Transition component now supports rendering Vapor components

Copy link

netlify bot commented Feb 27, 2025

Deploy Preview for vapor-repl ready!

Name Link
🔨 Latest commit af2eb2d
🔍 Latest deploy log https://app.netlify.com/sites/vapor-repl/deploys/67d1a09f4e46ac0008b2d1fe
😎 Deploy Preview https://deploy-preview-12962--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 site configuration.

Copy link

pkg-pr-new bot commented Feb 27, 2025

Open in Stackblitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-ssr

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

@vue/compiler-vapor

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

@vue/compiler-sfc

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

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@12962

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/runtime-vapor

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

@vue/server-renderer

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

@vue/shared

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

vue

npm i https://pkg.pr.new/vue@12962

@vue/compat

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

commit: af2eb2d

@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from 47e4e13 to 71db1e0 Compare February 27, 2025 09:29
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from 71db1e0 to 41822e3 Compare February 27, 2025 09:36
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch 2 times, most recently from a6362cb to 989e79f Compare March 3, 2025 14:04
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from 989e79f to 1e79054 Compare March 3, 2025 14:07
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from 93a4de3 to f139002 Compare March 4, 2025 12:14
@edison1105 edison1105 added the scope: vapor related to vapor mode label Mar 4, 2025
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from f139002 to 841e0cf Compare March 4, 2025 13:12
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from 841e0cf to 11bcb21 Compare March 4, 2025 14:02
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from 1b5e9ef to 27d15c5 Compare March 5, 2025 01:06
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from 27d15c5 to 3fcba1d Compare March 5, 2025 01:26
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from 44be78b to afc732e Compare March 5, 2025 09:13
@edison1105 edison1105 marked this pull request as ready for review March 7, 2025 08:20
@edison1105 edison1105 marked this pull request as draft March 7, 2025 14:19
@edison1105 edison1105 marked this pull request as ready for review March 8, 2025 02:00
edison1105 and others added 2 commits March 9, 2025 22:11
* wip: save

* wip: save

* wip: handle tag prop and attrs fallthrough

* test: add e2e tests

* [autofix.ci] apply automated fixes

* wip: add more tests

* [autofix.ci] apply automated fixes

* wip: handle vdom interop

* [autofix.ci] apply automated fixes

* wip: vapor interop + filter out reserved props

* [autofix.ci] apply automated fixes

* fix: tests

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
@edison1105 edison1105 changed the title feat(vapor): vapor transition feat(vapor): vapor transition + transition-group Mar 11, 2025
@edison1105 edison1105 marked this pull request as draft March 12, 2025 13:40
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch 2 times, most recently from b970e87 to 0e68999 Compare March 12, 2025 14:53
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from 0e68999 to af2eb2d Compare March 12, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: vapor related to vapor mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant