@@ -82,6 +82,10 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
82
82
const needTagForRuntime =
83
83
node . tag === 'textarea' || node . tag . indexOf ( '-' ) > 0
84
84
85
+ const hasVModel = node . props . some (
86
+ p => p . type === NodeTypes . DIRECTIVE && p . name === 'model' ,
87
+ )
88
+
85
89
// v-bind="obj", v-bind:[key] and custom directives can potentially
86
90
// overwrite other static attrs and can affect final rendering result,
87
91
// so when they are present we need to bail out to full `renderAttrs`
@@ -141,21 +145,24 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
141
145
)
142
146
}
143
147
} else if ( node . tag === 'select' ) {
144
- // <select> with dynamic v-bind. We don't know if the final props
145
- // will contain .value, so we will have to do something special:
146
- // assign the merged props to a temp variable, and check whether
147
- // it contains value (if yes, mark options selected).
148
- const tempId = `_temp${ context . temps ++ } `
149
- propsExp . arguments = [
150
- createAssignmentExpression (
151
- createSimpleExpression ( tempId , false ) ,
152
- mergedProps ,
153
- ) ,
154
- ]
155
- processSelectChildren ( context , node . children , {
156
- type : 'dynamicVBind' ,
157
- tempId,
158
- } )
148
+ // v-model takes priority over value
149
+ if ( ! hasVModel ) {
150
+ // <select> with dynamic v-bind. We don't know if the final props
151
+ // will contain .value, so we will have to do something special:
152
+ // assign the merged props to a temp variable, and check whether
153
+ // it contains value (if yes, mark options selected).
154
+ const tempId = `_temp${ context . temps ++ } `
155
+ propsExp . arguments = [
156
+ createAssignmentExpression (
157
+ createSimpleExpression ( tempId , false ) ,
158
+ mergedProps ,
159
+ ) ,
160
+ ]
161
+ processSelectChildren ( context , node . children , {
162
+ type : 'dynamicVBind' ,
163
+ tempId,
164
+ } )
165
+ }
159
166
} else if ( node . tag === 'input' ) {
160
167
// <input v-bind="obj" v-model>
161
168
// we need to determine the props to render for the dynamic v-model
@@ -245,7 +252,7 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
245
252
node . children = [ createInterpolation ( prop . exp , prop . loc ) ]
246
253
}
247
254
} else if ( isTagWithValueBind ( node , 'select' , prop ) && prop . exp ) {
248
- if ( ! needMergeProps ) {
255
+ if ( ! needMergeProps && ! hasVModel ) {
249
256
processSelectChildren ( context , node . children , {
250
257
type : 'dynamicValue' ,
251
258
value : prop . exp ,
@@ -351,7 +358,7 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
351
358
if ( node . tag === 'textarea' && name === 'value' && prop . value ) {
352
359
rawChildrenMap . set ( node , escapeHtml ( prop . value . content ) )
353
360
} else if ( node . tag === 'select' && name === 'value' && prop . value ) {
354
- if ( ! needMergeProps ) {
361
+ if ( ! needMergeProps && ! hasVModel ) {
355
362
processSelectChildren ( context , node . children , {
356
363
type : 'staticValue' ,
357
364
value : prop . value . content ,
0 commit comments