Prevent creating invalid closing tags
fixes #2756
JD Isaacks committed
Jun 23, 2015 at 15:57 UTC
d944d3f9419ee7e57afc2865dcfdf2d092111cd5
2 files changed
+13
-3
src/renderers/dom/shared/ReactDOMComponent.js
+3
-3
@@ -438,7 +438,7 @@ function isCustomComponent(tagName, props) {
438
*/
439
function ReactDOMComponent(tag) {
440
validateDangerousTag(tag);
441
- this._tag = tag;
441
+ this._tag = tag.toLowerCase();
442
this._renderedChildren = null;
443
this._previousStyle = null;
444
this._previousStyleCopy = null;
@@ -533,7 +533,7 @@ ReactDOMComponent.Mixin = {
533
if (!tagContent && omittedCloseTags[this._tag]) {
534
return tagOpen + '/>';
535
}
536
- return tagOpen + '>' + tagContent + '</' + this._tag + '>';
536
+ return tagOpen + '>' + tagContent + '</' + this._currentElement.type + '>';
537
},
538
539
/**
@@ -550,7 +550,7 @@ ReactDOMComponent.Mixin = {
550
* @return {string} Markup of opening tag.
551
*/
552
_createOpenTagMarkupAndPutListeners: function(transaction, props) {
553
- var ret = '<' + this._tag;
553
+ var ret = '<' + this._currentElement.type;
554
555
for (var propKey in props) {
556
if (!props.hasOwnProperty(propKey)) {
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+10
@@ -452,6 +452,16 @@ describe('ReactDOMComponent', function() {
452
};
453
});
454
455
+ it('should not duplicate uppercased selfclosing tags', function() {
456
+ var Container = React.createClass({
457
+ render: function() {
458
+ return React.createElement('BR', null);
459
+ },
460
+ });
461
+ var returnedValue = React.renderToString(<Container/>);
462
+ expect(returnedValue).not.toContain('</BR>');
463
+ });
464
+
465
it('should warn against children for void elements', function() {
466
spyOn(console, 'error');
467