@@ -34,7 +34,7 @@ let shallowRender = (vnode, context) => renderToString(vnode, context, SHALLOW);
34
34
35
35
36
36
/** The default export is an alias of `render()`. */
37
- function renderToString ( vnode , context , opts , inner , isSvgMode ) {
37
+ function renderToString ( vnode , context , opts , inner , isSvgMode , selectValue ) {
38
38
if ( vnode == null || typeof vnode === 'boolean' ) {
39
39
return '' ;
40
40
}
@@ -65,7 +65,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode) {
65
65
getChildren ( children , vnode . props . children ) ;
66
66
67
67
for ( let i = 0 ; i < children . length ; i ++ ) {
68
- rendered += renderToString ( children [ i ] , context , opts , opts . shallowHighOrder !== false , isSvgMode ) ;
68
+ rendered += renderToString ( children [ i ] , context , opts , opts . shallowHighOrder !== false , isSvgMode , selectValue ) ;
69
69
}
70
70
return rendered ;
71
71
}
@@ -97,7 +97,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode) {
97
97
context = assign ( assign ( { } , context ) , c . getChildContext ( ) ) ;
98
98
}
99
99
100
- return renderToString ( rendered , context , opts , opts . shallowHighOrder !== false ) ;
100
+ return renderToString ( rendered , context , opts , opts . shallowHighOrder !== false , isSvgMode , selectValue ) ;
101
101
}
102
102
}
103
103
@@ -149,6 +149,16 @@ function renderToString(vnode, context, opts, inner, isSvgMode) {
149
149
continue ;
150
150
}
151
151
}
152
+
153
+ if ( name === 'value' ) {
154
+ if ( nodeName === 'select' ) {
155
+ selectValue = v ;
156
+ continue ;
157
+ }
158
+ else if ( nodeName === 'option' && selectValue == v ) {
159
+ s += ` selected` ;
160
+ }
161
+ }
152
162
s += ` ${ name } ="${ encodeEntities ( v ) } "` ;
153
163
}
154
164
}
@@ -183,7 +193,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode) {
183
193
let child = children [ i ] ;
184
194
if ( child != null && child !== false ) {
185
195
let childSvgMode = nodeName === 'svg' ? true : nodeName === 'foreignObject' ? false : isSvgMode ,
186
- ret = renderToString ( child , context , opts , true , childSvgMode ) ;
196
+ ret = renderToString ( child , context , opts , true , childSvgMode , selectValue ) ;
187
197
if ( pretty && ! hasLarge && isLargeString ( ret ) ) hasLarge = true ;
188
198
if ( ret ) pieces . push ( ret ) ;
189
199
}
0 commit comments