Fix handling of newlines in textarea input

This commit is contained in:
Jean-Marc Fontaine
2012-12-13 15:00:16 +01:00
committed by vitalets
parent 19f227f83c
commit 1159e26e34
2 changed files with 8 additions and 2 deletions
src/inputs
test/unit

@@ -53,7 +53,13 @@ $(function(){
}
var lines = html.split(/<br\s*\/?>/i);
for (var i = 0; i < lines.length; i++) {
lines[i] = $('<div>').html(lines[i]).text();
var text = $('<div>').html(lines[i]).text();
// Remove newline characters (\n) to avoid them being converted by value2html() method
// thus adding extra <br> tags
text = text.replace(new RegExp(String.fromCharCode(10), 'g'), '');
lines[i] = text;
}
return lines.join("\n");
},