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

Fix #8105 #8641

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions packages/runtime-core/src/components/Suspense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ function createSuspenseBoundary(
m: move,
um: unmount,
n: next,
o: { parentNode, remove }
o: { nextSibling, parentNode, remove }
} = rendererInternals

// if set `suspensible: true`, set the current suspense as a dep of parent suspense
Expand Down Expand Up @@ -494,28 +494,42 @@ function createSuspenseBoundary(
if (suspense.isHydrating) {
suspense.isHydrating = false
} else if (!resume) {
const anchorCands: RendererNode[] = []
if (activeBranch) {
for (let node = next(activeBranch); node; node = nextSibling(node)) {
anchorCands.push(node)
}
}

// this is initial anchor on mount
const { anchor: initialAnchor } = suspense

const delayEnter =
activeBranch &&
pendingBranch!.transition &&
pendingBranch!.transition.mode === 'out-in'

if (delayEnter) {
activeBranch!.transition!.afterLeave = () => {
if (pendingId === suspense.pendingId) {
const anchor =
anchorCands.find(x => parentNode(x) === container) ||
initialAnchor
move(pendingBranch!, container, anchor, MoveType.ENTER)
}
}
}
// this is initial anchor on mount
let { anchor } = suspense

// unmount current active tree
if (activeBranch) {
// if the fallback tree was mounted, it may have been moved
// as part of a parent suspense. get the latest anchor for insertion
anchor = next(activeBranch)
unmount(activeBranch, parentComponent, suspense, true)
}
if (!delayEnter) {
// move content from off-dom container to actual container
const anchor =
anchorCands.find(x => parentNode(x) === container) || initialAnchor
move(pendingBranch!, container, anchor, MoveType.ENTER)
}
}
Expand Down
10 changes: 10 additions & 0 deletions packages/vue/__tests__/e2e/Transition.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,16 @@ describe('e2e: Transition', () => {
// )
await transitionFinish()
expect(await html('#container')).toBe('<div class="test">two</div>')

// toggle rapidly #8105
await click('#toggleBtn')
await nextFrame()
await click('#toggleBtn')

// wait for awhile
await transitionFinish(duration * 3)

expect(await html('#container')).toBe('<div class="test">two</div>')
},
E2E_TIMEOUT
)
Expand Down