From 030a7b34c7ee3a92fad8113249d399db5c41ea71 Mon Sep 17 00:00:00 2001 From: Austin Wright Date: Mon, 23 Feb 2015 13:58:40 -0700 Subject: [PATCH] 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. --- src/browser/ui/ReactDOMComponent.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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; }