Add back \n-to-be-eaten for the plain-text elements

The comment hack to enable polyglot HTML isn't cross-browser, or simply doesn't work.
This commit is contained in:
Austin Wright
2015-03-14 13:53:12 -07:00
parent 8e714f9898
commit 030a7b34c7
+6 -3
View File
@@ -306,14 +306,17 @@ ReactDOMComponent.Mixin = {
|| this._tag === 'textarea')
&& ret.charAt(0) === '\n'
) {
// Add an invisible node that's not a newline, because the HTML syntax
// ignores the first character in these tags if it's a newline
// text/html ignores the first character in these tags if it's a newline
// Prefer to break application/xml over text/html (for now) by adding
// a newline specifically to get eaten by the parser.
// (Alternately for textareas, replacing "^\n" with "\r\n" doesn't get eaten,
// and the first \r is normalized out by HTMLTextAreaElement#value.)
// See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
// See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
// See: <http://www.w3.org/TR/html5/syntax.html#newlines>
// See: Parsing of "textarea" "listing" and "pre" elements
// from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
return '<!---->' + ret;
return '\n' + ret;
} else {
return ret;
}