Move list of newline-eating tags to variable
Austin Wright committed
Mar 14, 2015 at 13:57 UTC
b52bb2234231c417d9535d765bf2ddd585f79027
1 file changed
+7
-6
src/browser/ui/ReactDOMComponent.js
+7
-6
@@ -144,6 +144,12 @@ var omittedCloseTags = {
144
// NOTE: menuitem's close tag should be omitted, but that causes problems.
145
};
146
147
+var newlineEatingTags = {
148
+ 'listing': true,
149
+ 'pre': true,
150
+ 'textarea': true
151
+};
152
+
153
// For HTML, certain tags cannot have children. This has the same purpose as
154
// `omittedCloseTags` except that `menuitem` should still have its closing tag.
155
@@ -300,12 +306,7 @@ ReactDOMComponent.Mixin = {
306
ret = mountImages.join('');
307
}
308
}
303
- if (
304
- (this._tag === 'listing'
305
- || this._tag === 'pre'
306
- || this._tag === 'textarea')
307
- && ret.charAt(0) === '\n'
308
- ) {
309
+ if (newlineEatingTags[this._tag] && ret.charAt(0) === '\n') {
310
// text/html ignores the first character in these tags if it's a newline
311
// Prefer to break application/xml over text/html (for now) by adding
312
// a newline specifically to get eaten by the parser.