Prevent creating invalid closing tags

fixes #2756
This commit is contained in:
JD Isaacks
2015-06-23 15:57:47 -04:00
parent c5fb3ff987
commit d944d3f941
2 changed files with 13 additions and 3 deletions
@@ -438,7 +438,7 @@ function isCustomComponent(tagName, props) {
*/
function ReactDOMComponent(tag) {
validateDangerousTag(tag);
this._tag = tag;
this._tag = tag.toLowerCase();
this._renderedChildren = null;
this._previousStyle = null;
this._previousStyleCopy = null;
@@ -533,7 +533,7 @@ ReactDOMComponent.Mixin = {
if (!tagContent && omittedCloseTags[this._tag]) {
return tagOpen + '/>';
}
return tagOpen + '>' + tagContent + '</' + this._tag + '>';
return tagOpen + '>' + tagContent + '</' + this._currentElement.type + '>';
},
/**
@@ -550,7 +550,7 @@ ReactDOMComponent.Mixin = {
* @return {string} Markup of opening tag.
*/
_createOpenTagMarkupAndPutListeners: function(transaction, props) {
var ret = '<' + this._tag;
var ret = '<' + this._currentElement.type;
for (var propKey in props) {
if (!props.hasOwnProperty(propKey)) {
@@ -452,6 +452,16 @@ describe('ReactDOMComponent', function() {
};
});
it('should not duplicate uppercased selfclosing tags', function() {
var Container = React.createClass({
render: function() {
return React.createElement('BR', null);
},
});
var returnedValue = React.renderToString(<Container/>);
expect(returnedValue).not.toContain('</BR>');
});
it('should warn against children for void elements', function() {
spyOn(console, 'error');