Skip to content

Commit 76eda75

Browse files
authored
Don't serialize empty textarea value
1 parent c7f9146 commit 76eda75

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
196196
if (name==='dangerouslySetInnerHTML') {
197197
html = v && v.__html;
198198
}
199+
else if (nodeName === 'textarea' && name === 'value') {
200+
// <textarea value="a&b"> --> <textarea>a&amp;b</textarea>
201+
propChildren = v;
202+
}
199203
else if ((v || v===0 || v==='') && typeof v!=='function') {
200204
if (v===true || v==='') {
201205
v = name;
@@ -207,12 +211,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
207211
}
208212

209213
if (name==='value') {
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') {
214+
if (nodeName==='select') {
216215
selectValue = v;
217216
continue;
218217
}
@@ -248,7 +247,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
248247
}
249248
s += html;
250249
}
251-
else if (propChildren && getChildren(children = [], propChildren).length) {
250+
else if (props && getChildren(children = [], propChildren).length) {
252251
let hasLarge = pretty && ~s.indexOf('\n');
253252
let lastWasText = false;
254253

0 commit comments

Comments
 (0)