mirror of https://github.com/vuejs/core.git
fix(compiler-ssr): disable v-memo transform in ssr vdom fallback branch (#13725)
close #13724
This commit is contained in:
parent
d9dd628800
commit
0a202d890f
|
|
@ -16,7 +16,7 @@ const seen = new WeakSet()
|
|||
export const transformMemo: NodeTransform = (node, context) => {
|
||||
if (node.type === NodeTypes.ELEMENT) {
|
||||
const dir = findDir(node, 'memo')
|
||||
if (!dir || seen.has(node)) {
|
||||
if (!dir || seen.has(node) || context.inSSR) {
|
||||
return
|
||||
}
|
||||
seen.add(node)
|
||||
|
|
|
|||
|
|
@ -317,6 +317,35 @@ describe('ssr: components', () => {
|
|||
`)
|
||||
})
|
||||
|
||||
// #13724
|
||||
test('slot content with v-memo', () => {
|
||||
const { code } = compile(`<foo><bar v-memo="[]" /></foo>`)
|
||||
expect(code).not.toMatch(`_cache`)
|
||||
expect(compile(`<foo><bar v-memo="[]" /></foo>`).code)
|
||||
.toMatchInlineSnapshot(`
|
||||
"const { resolveComponent: _resolveComponent, withCtx: _withCtx, createVNode: _createVNode } = require("vue")
|
||||
const { ssrRenderComponent: _ssrRenderComponent } = require("vue/server-renderer")
|
||||
|
||||
return function ssrRender(_ctx, _push, _parent, _attrs) {
|
||||
const _component_foo = _resolveComponent("foo")
|
||||
const _component_bar = _resolveComponent("bar")
|
||||
|
||||
_push(_ssrRenderComponent(_component_foo, _attrs, {
|
||||
default: _withCtx((_, _push, _parent, _scopeId) => {
|
||||
if (_push) {
|
||||
_push(_ssrRenderComponent(_component_bar, null, null, _parent, _scopeId))
|
||||
} else {
|
||||
return [
|
||||
_createVNode(_component_bar)
|
||||
]
|
||||
}
|
||||
}),
|
||||
_: 1 /* STABLE */
|
||||
}, _parent))
|
||||
}"
|
||||
`)
|
||||
})
|
||||
|
||||
describe('built-in fallthroughs', () => {
|
||||
test('transition', () => {
|
||||
expect(compile(`<transition><div/></transition>`).code)
|
||||
|
|
|
|||
Loading…
Reference in New Issue