From 8bc828aa7c90fe13f4957792a50ddbbe99077173 Mon Sep 17 00:00:00 2001 From: Austin Wright Date: Mon, 12 Jan 2015 11:45:28 -0700 Subject: [PATCH 1/6] Generate XML-compatible tags and boolean attributes --- src/browser/ui/ReactDOMComponent.js | 16 ++++++++-------- src/browser/ui/dom/DOMPropertyOperations.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/browser/ui/ReactDOMComponent.js b/src/browser/ui/ReactDOMComponent.js index cf93f29b86d..b73403f49ad 100644 --- a/src/browser/ui/ReactDOMComponent.js +++ b/src/browser/ui/ReactDOMComponent.js @@ -208,12 +208,12 @@ ReactDOMComponent.Mixin = { mountComponent: function(rootID, transaction, context) { this._rootNodeID = rootID; assertValidProps(this, this._currentElement.props); - var closeTag = omittedCloseTags[this._tag] ? '' : ''; - return ( - this._createOpenTagMarkupAndPutListeners(transaction) + - this._createContentMarkup(transaction, context) + - closeTag - ); + var tagOpen = this._createOpenTagMarkupAndPutListeners(transaction); + var tagContent = this._createContentMarkup(transaction, context); + if(!tagContent && omittedCloseTags[this._tag]){ + return tagOpen + '/>'; + } + return tagOpen + '>' + tagContent + ''; }, /** @@ -260,11 +260,11 @@ ReactDOMComponent.Mixin = { // For static pages, no need to put React ID and checksum. Saves lots of // bytes. if (transaction.renderToStaticMarkup) { - return ret + '>'; + return ret; } var markupForID = DOMPropertyOperations.createMarkupForID(this._rootNodeID); - return ret + ' ' + markupForID + '>'; + return ret + ' ' + markupForID; }, /** diff --git a/src/browser/ui/dom/DOMPropertyOperations.js b/src/browser/ui/dom/DOMPropertyOperations.js index 192aee14279..f049403184c 100644 --- a/src/browser/ui/dom/DOMPropertyOperations.js +++ b/src/browser/ui/dom/DOMPropertyOperations.js @@ -96,7 +96,7 @@ var DOMPropertyOperations = { var attributeName = DOMProperty.getAttributeName[name]; if (DOMProperty.hasBooleanValue[name] || (DOMProperty.hasOverloadedBooleanValue[name] && value === true)) { - return attributeName; + return attributeName + '=""'; } return attributeName + '=' + quoteAttributeValueForBrowser(value); } else if (DOMProperty.isCustomAttribute(name)) { From e913e85e1ad82c5251492602afbc8186c1389f13 Mon Sep 17 00:00:00 2001 From: Austin Wright Date: Mon, 12 Jan 2015 18:10:45 -0700 Subject: [PATCH 2/6] Use a Polyglot HTML-safe method of escaping leading newline in rawtext elements --- src/browser/ui/ReactDOMComponent.js | 35 +++++++++++++++++------------ 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/browser/ui/ReactDOMComponent.js b/src/browser/ui/ReactDOMComponent.js index b73403f49ad..d596315a39b 100644 --- a/src/browser/ui/ReactDOMComponent.js +++ b/src/browser/ui/ReactDOMComponent.js @@ -276,40 +276,47 @@ ReactDOMComponent.Mixin = { * @return {string} Content markup. */ _createContentMarkup: function(transaction, context) { - var prefix = ''; - if (this._tag === 'listing' || - this._tag === 'pre' || - this._tag === 'textarea') { - // Add an initial newline because browsers ignore the first newline in - // a ,
, or