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

Open
wants to merge 62 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
    • TransitionGroup is automatically rewritten as VaporTransitionGroup
  • 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
      })
    }
  })
  • When appear is set in the Transition and the root node uses v-show, it need to execute applyVShow after the Transition is created to ensure that the appear behavior works properly.
  <div>
    <transition appear>
      <div v-show="!toggle">content</div>
    </transition>
  </div>

will be compiled to

  const deferredApplyVShows = []
  const n2 = t1()
  const n1 = _createComponent(_VaporTransition, {
    appear: () => (""), 
    persisted: () => ("")
  }, {
    "default": () => {
      const n0 = t0()
      deferredApplyVShows.push(() => _applyVShow(n0, () => (!toggle.value)))
      return n0
    }
  })
  _insert(n1, n2)
  deferredApplyVShows.forEach(fn => fn())
  return n2

Runtime Changes

  • Added VaporTransition and VaporTransitionGroup components 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

Tests

  • Ported all test cases except those related to KeepAlive, Suspense, and Teleport from packages/vue/tests/e2e/Transition.spec.ts
  • Ported all test cases from packages/vue/tests/e2e/TransitionGroup.spec.ts

Copy link

netlify bot commented Feb 27, 2025

Deploy Preview for vapor-repl ready!

Name Link
🔨 Latest commit d8ccabe
🔍 Latest deploy log https://app.netlify.com/sites/vapor-repl/deploys/67da13805c13d40008e2c0df
😎 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-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@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/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: d8ccabe

@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 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
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from 3048952 to 9ee219a Compare March 14, 2025 06:40
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from d486cf8 to 2caeecd Compare March 14, 2025 09:37
@edison1105 edison1105 force-pushed the edison/feat/vaporTransition branch from 4c016a8 to e42ff1b Compare March 17, 2025 06:52
@edison1105 edison1105 marked this pull request as ready for review March 17, 2025 06:57
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