fix(compiler-ssr): fix input w/ v-bind="obj" codegen

This commit is contained in:
Evan You
2020-03-16 18:14:49 -04:00
parent 9eef37fa32
commit 3b40fc56db
4 changed files with 48 additions and 14 deletions

View File

@@ -118,7 +118,7 @@ describe('ssr: v-model', () => {
return function ssrRender(_ctx, _push, _parent) {
let _temp0
_push(\`<input\${_ssrRenderAttrs(_temp0 = _ctx.obj, _mergeProps(_temp0, _ssrGetDynamicModelProps(_temp0, _ctx.foo)))}>\`)
_push(\`<input\${_ssrRenderAttrs((_temp0 = _ctx.obj, _mergeProps(_temp0, _ssrGetDynamicModelProps(_temp0, _ctx.foo))))}>\`)
}"
`)
@@ -130,7 +130,7 @@ describe('ssr: v-model', () => {
return function ssrRender(_ctx, _push, _parent) {
let _temp0
_push(\`<input\${_ssrRenderAttrs(_temp0 = _mergeProps({ id: \\"x\\" }, _ctx.obj, { class: \\"y\\" }), _mergeProps(_temp0, _ssrGetDynamicModelProps(_temp0, _ctx.foo)))}>\`)
_push(\`<input\${_ssrRenderAttrs((_temp0 = _mergeProps({ id: \\"x\\" }, _ctx.obj, { class: \\"y\\" }), _mergeProps(_temp0, _ssrGetDynamicModelProps(_temp0, _ctx.foo))))}>\`)
}"
`)
})

View File

@@ -22,7 +22,8 @@ import {
TextNode,
hasDynamicKeyVBind,
MERGE_PROPS,
isBindKey
isBindKey,
createSequenceExpression
} from '@vue/compiler-dom'
import {
escapeHtml,
@@ -107,16 +108,18 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
const tempId = `_temp${context.temps++}`
const tempExp = createSimpleExpression(tempId, false)
propsExp.arguments = [
createAssignmentExpression(tempExp, props),
createCallExpression(context.helper(MERGE_PROPS), [
tempExp,
createCallExpression(
context.helper(SSR_GET_DYNAMIC_MODEL_PROPS),
[
tempExp, // existing props
vModel.exp! // model
]
)
createSequenceExpression([
createAssignmentExpression(tempExp, props),
createCallExpression(context.helper(MERGE_PROPS), [
tempExp,
createCallExpression(
context.helper(SSR_GET_DYNAMIC_MODEL_PROPS),
[
tempExp, // existing props
vModel.exp! // model
]
)
])
])
]
}