JS_TEMPLATE_LITERAL,
JS_IF_STATEMENT,
JS_ASSIGNMENT_EXPRESSION,
+ JS_SEQUENCE_EXPRESSION,
JS_RETURN_STATEMENT
}
| ConditionalExpression
| CacheExpression
| AssignmentExpression
+ | SequenceExpression
export interface CallExpression extends Node {
type: NodeTypes.JS_CALL_EXPRESSION
| IfStatement
| AssignmentExpression
| ReturnStatement
+ | SequenceExpression
export interface BlockStatement extends Node {
type: NodeTypes.JS_BLOCK_STATEMENT
right: JSChildNode
}
+export interface SequenceExpression extends Node {
+ type: NodeTypes.JS_SEQUENCE_EXPRESSION
+ expressions: JSChildNode[]
+}
+
export interface ReturnStatement extends Node {
type: NodeTypes.JS_RETURN_STATEMENT
returns: TemplateChildNode | TemplateChildNode[] | JSChildNode
}
}
+export function createSequenceExpression(
+ expressions: SequenceExpression['expressions']
+): SequenceExpression {
+ return {
+ type: NodeTypes.JS_SEQUENCE_EXPRESSION,
+ expressions,
+ loc: locStub
+ }
+}
+
export function createReturnStatement(
returns: ReturnStatement['returns']
): ReturnStatement {
IfStatement,
AssignmentExpression,
ReturnStatement,
- VNodeCall
+ VNodeCall,
+ SequenceExpression
} from './ast'
import { SourceMapGenerator, RawSourceMap } from 'source-map'
import {
case NodeTypes.JS_ASSIGNMENT_EXPRESSION:
!__BROWSER__ && genAssignmentExpression(node, context)
break
+ case NodeTypes.JS_SEQUENCE_EXPRESSION:
+ !__BROWSER__ && genSequenceExpression(node, context)
+ break
case NodeTypes.JS_RETURN_STATEMENT:
!__BROWSER__ && genReturnStatement(node, context)
break
genNode(node.right, context)
}
+function genSequenceExpression(
+ node: SequenceExpression,
+ context: CodegenContext
+) {
+ context.push(`(`)
+ genNodeList(node.expressions, context)
+ context.push(`)`)
+}
+
function genReturnStatement(
{ returns }: ReturnStatement,
context: CodegenContext
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))))}>\`)
}"
`)
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))))}>\`)
}"
`)
})
TextNode,
hasDynamicKeyVBind,
MERGE_PROPS,
- isBindKey
+ isBindKey,
+ createSequenceExpression
} from '@vue/compiler-dom'
import {
escapeHtml,
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
+ ]
+ )
+ ])
])
]
}