-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
feat(ssr): transition appear work with SSR #8859
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ad1c4ad
feat(ssr): transition appear work with SSR
edison1105 7d431a1
chore: improve code
edison1105 02a64f5
test: add test case
edison1105 c6d3962
feat: work with vshow
edison1105 ab06b28
Merge branch 'main' into feature/SSRTransition
edison1105 db5a631
chore: update test
edison1105 79bcaff
chore: improve code
edison1105 7474479
chore: improve code
edison1105 b0d82c8
chore: remove replace function
edison1105 593eb10
chore: remove replace function
edison1105 7fcfc0a
Merge branch 'main' into feature/SSRTransition
edison1105 af04252
chore: rebase
edison1105 86055dd
chore: rebase
edison1105 695a02f
Merge branch 'main' into feature/SSRTransition
edison1105 d36f2f3
chore: improve code
edison1105 9ffd49e
chore: improve code
edison1105 fbbf56c
Update ssrTransformComponent.ts
edison1105 7b3e692
Update ssrTransformTransition.ts
edison1105 28040ee
Update ssrTransformTransition.ts
edison1105 3fabcf7
Update ssrTransformTransition.ts
edison1105 70f9bce
chore: avoid exposing vShowOldKey as public API
yyx990803 d7a7bbd
chore: minor tweaks
yyx990803 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { compile } from '../src' | ||
|
||
describe('transition', () => { | ||
test('basic', () => { | ||
expect(compile(`<transition><div>foo</div></transition>`).code) | ||
.toMatchInlineSnapshot(` | ||
"const { ssrRenderAttrs: _ssrRenderAttrs } = require(\\"vue/server-renderer\\") | ||
|
||
return function ssrRender(_ctx, _push, _parent, _attrs) { | ||
_push(\`<div\${_ssrRenderAttrs(_attrs)}>foo</div>\`) | ||
}" | ||
`) | ||
}) | ||
|
||
test('with appear', () => { | ||
expect(compile(`<transition appear><div>foo</div></transition>`).code) | ||
.toMatchInlineSnapshot(` | ||
"const { ssrRenderAttrs: _ssrRenderAttrs } = require(\\"vue/server-renderer\\") | ||
|
||
return function ssrRender(_ctx, _push, _parent, _attrs) { | ||
_push(\`<template><div\${_ssrRenderAttrs(_attrs)}>foo</div></template>\`) | ||
}" | ||
`) | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/compiler-ssr/src/transforms/ssrTransformTransition.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
ComponentNode, | ||
findProp, | ||
NodeTypes, | ||
TransformContext | ||
} from '@vue/compiler-dom' | ||
import { processChildren, SSRTransformContext } from '../ssrCodegenTransform' | ||
|
||
const wipMap = new WeakMap<ComponentNode, Boolean>() | ||
|
||
export function ssrTransformTransition( | ||
node: ComponentNode, | ||
context: TransformContext | ||
) { | ||
return () => { | ||
const appear = findProp(node, 'appear', false, true) | ||
wipMap.set(node, !!appear) | ||
} | ||
} | ||
|
||
export function ssrProcessTransition( | ||
node: ComponentNode, | ||
context: SSRTransformContext | ||
) { | ||
// #5351: filter out comment children inside transition | ||
node.children = node.children.filter(c => c.type !== NodeTypes.COMMENT) | ||
|
||
const appear = wipMap.get(node) | ||
if (appear) { | ||
context.pushStringPart(`<template>`) | ||
processChildren(node, context, false, true) | ||
context.pushStringPart(`</template>`) | ||
} else { | ||
processChildren(node, context, false, true) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.