Generate XML-compatible tags and boolean attributes
Austin Wright committed
Jan 12, 2015 at 11:45 UTC
8bc828aa7c90fe13f4957792a50ddbbe99077173
2 files changed
+9
-9
src/browser/ui/ReactDOMComponent.js
+8
-8
@@ -208,12 +208,12 @@ ReactDOMComponent.Mixin = {
208
mountComponent: function(rootID, transaction, context) {
209
this._rootNodeID = rootID;
210
assertValidProps(this, this._currentElement.props);
211
- var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
212
- return (
213
- this._createOpenTagMarkupAndPutListeners(transaction) +
214
- this._createContentMarkup(transaction, context) +
215
- closeTag
216
- );
211
+ var tagOpen = this._createOpenTagMarkupAndPutListeners(transaction);
212
+ var tagContent = this._createContentMarkup(transaction, context);
213
+ if(!tagContent && omittedCloseTags[this._tag]){
214
+ return tagOpen + '/>';
215
+ }
216
+ return tagOpen + '>' + tagContent + '</' + this._tag + '>';
217
},
218
219
/**
@@ -260,11 +260,11 @@ ReactDOMComponent.Mixin = {
260
// For static pages, no need to put React ID and checksum. Saves lots of
261
// bytes.
262
if (transaction.renderToStaticMarkup) {
263
- return ret + '>';
263
+ return ret;
264
}
265
266
var markupForID = DOMPropertyOperations.createMarkupForID(this._rootNodeID);
267
- return ret + ' ' + markupForID + '>';
267
+ return ret + ' ' + markupForID;
268
},
269
270
/**
src/browser/ui/dom/DOMPropertyOperations.js
+1
-1
@@ -96,7 +96,7 @@ var DOMPropertyOperations = {
96
var attributeName = DOMProperty.getAttributeName[name];
97
if (DOMProperty.hasBooleanValue[name] ||
98
(DOMProperty.hasOverloadedBooleanValue[name] && value === true)) {
99
- return attributeName;
99
+ return attributeName + '=""';
100
}
101
return attributeName + '=' + quoteAttributeValueForBrowser(value);
102
} else if (DOMProperty.isCustomAttribute(name)) {