mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user