diff --git a/src/browser/ui/ReactDOMComponent.js b/src/browser/ui/ReactDOMComponent.js index d596315a39..aa8a181b56 100644 --- a/src/browser/ui/ReactDOMComponent.js +++ b/src/browser/ui/ReactDOMComponent.js @@ -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: // See: // See: // See: Parsing of "textarea" "listing" and "pre" elements // from - return '' + ret; + return '\n' + ret; } else { return ret; }