Skip to content

Commit 0351298

Browse files
authored
Fix SSR for <textarea value>
1 parent 81c3cdc commit 0351298

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,11 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
145145
}
146146

147147
// render JSX to HTML
148-
let s = '', html;
148+
let s = '', propChildren, html;
149149

150150
if (props) {
151+
propChildren = props.children;
152+
151153
let attrs = Object.keys(props);
152154

153155
// allow sorting lexicographically for more determinism (useful for tests, such as via preact-jsx-chai)
@@ -205,7 +207,12 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
205207
}
206208

207209
if (name==='value') {
208-
if (nodeName==='select') {
210+
if (nodeName==='textarea') {
211+
// <textarea value="a&b"> --> <textarea>a&amp;b</textarea>
212+
propChildren = v;
213+
continue;
214+
}
215+
else if (nodeName==='select') {
209216
selectValue = v;
210217
continue;
211218
}
@@ -241,7 +248,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
241248
}
242249
s += html;
243250
}
244-
else if (props && getChildren(children = [], props.children).length) {
251+
else if (propChildren && getChildren(children = [], propChildren).length) {
245252
let hasLarge = pretty && ~s.indexOf('\n');
246253
let lastWasText = false;
247254

0 commit comments

Comments
 (0)