fix(v-model): should use dynamic directive on input with dynamic v-bind

This commit is contained in:
Evan You
2020-02-05 15:21:47 -05:00
parent ae92925011
commit 1f2de9e232
6 changed files with 72 additions and 11 deletions

View File

@@ -19,7 +19,8 @@ import {
JSChildNode,
ArrayExpression,
createAssignmentExpression,
TextNode
TextNode,
hasDynamicKeyVBind
} from '@vue/compiler-dom'
import { escapeHtml, isBooleanAttr, isSSRSafeAttrName } from '@vue/shared'
import { createSSRCompilerError, SSRErrorCodes } from '../errors'
@@ -46,14 +47,7 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
// v-bind="obj" or v-bind:[key] can potentially overwrite other static
// attrs and can affect final rendering result, so when they are present
// we need to bail out to full `renderAttrs`
const hasDynamicVBind = node.props.some(
p =>
p.type === NodeTypes.DIRECTIVE &&
p.name === 'bind' &&
(!p.arg || // v-bind="obj"
p.arg.type !== NodeTypes.SIMPLE_EXPRESSION || // v-bind:[_ctx.foo]
!p.arg.isStatic) // v-bind:[foo]
)
const hasDynamicVBind = hasDynamicKeyVBind(node)
if (hasDynamicVBind) {
const { props } = buildProps(node, context, node.props, true /* ssr */)
if (props) {

View File

@@ -96,7 +96,8 @@ export const ssrTransformModel: DirectiveTransform = (dir, node, context) => {
checkDuplicatedValue()
node.children = [createInterpolation(model, model.loc)]
} else if (node.tag === 'select') {
// TODO
// NOOP
// select relies on client-side directive to set initial selected state.
} else {
context.onError(
createDOMCompilerError(